extern int dry_run;
extern int read_only;
+extern int list_only;
-#define CHECK_RO if (read_only) {errno = EROFS; return -1;}
+#define CHECK_RO if (read_only || list_only) {errno = EROFS; return -1;}
int do_unlink(char *fname)
{
int do_open(char *pathname, int flags, mode_t mode)
{
- if (dry_run) return -1;
+ if (flags != O_RDONLY) {
+ if (dry_run) return -1;
+ CHECK_RO
+ }
#ifdef O_BINARY
/* for Windows */
flags |= O_BINARY;
#endif
- CHECK_RO
+ /* some systems can't handle a double / */
+ if (pathname[0] == '/' && pathname[1] == '/') pathname++;
+
return open(pathname, flags, mode);
}
{
if (dry_run) return NULL;
if (read_only) {errno = EROFS; return NULL;}
+
+ /* TODO: Replace this with a good builtin mkstemp, perhaps
+ * from OpenBSD. Some glibc versions are buggy. */
return mktemp(template);
}