2 Copyright (C) Andrew Tridgell 1998
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 syscall wrappers to ensure that nothing gets done in dry_run mode
29 #define CHECK_RO if (read_only || list_only) {errno = EROFS; return -1;}
31 int do_unlink(char *fname)
33 if (dry_run) return 0;
38 int do_symlink(char *fname1, char *fname2)
40 if (dry_run) return 0;
42 return symlink(fname1, fname2);
46 int do_link(char *fname1, char *fname2)
48 if (dry_run) return 0;
50 return link(fname1, fname2);
54 int do_lchown(const char *path, uid_t owner, gid_t group)
56 if (dry_run) return 0;
58 return lchown(path, owner, group);
62 int do_mknod(char *pathname, mode_t mode, dev_t dev)
64 if (dry_run) return 0;
66 return mknod(pathname, mode, dev);
70 int do_rmdir(char *pathname)
72 if (dry_run) return 0;
74 return rmdir(pathname);
77 int do_open(char *pathname, int flags, mode_t mode)
79 if (dry_run) return -1;
85 return open(pathname, flags, mode);
89 int do_chmod(const char *path, mode_t mode)
91 if (dry_run) return 0;
93 return chmod(path, mode);
97 int do_rename(char *fname1, char *fname2)
99 if (dry_run) return 0;
101 return rename(fname1, fname2);
104 int do_mkdir(char *fname, mode_t mode)
106 if (dry_run) return 0;
108 return mkdir(fname, mode);
111 char *do_mktemp(char *template)
113 if (dry_run) return NULL;
114 if (read_only) {errno = EROFS; return NULL;}
115 return mktemp(template);
118 int do_stat(const char *fname, STRUCT_STAT *st)
121 return stat64(fname, st);
123 return stat(fname, st);
128 int do_lstat(const char *fname, STRUCT_STAT *st)
131 return lstat64(fname, st);
133 return lstat(fname, st);
138 int do_fstat(int fd, STRUCT_STAT *st)
141 return fstat64(fd, st);
143 return fstat(fd, st);
147 OFF_T do_lseek(int fd, OFF_T offset, int whence)
151 return lseek64(fd, offset, whence);
153 return lseek(fd, offset, whence);
158 void *do_mmap(void *start, int len, int prot, int flags, int fd, OFF_T offset)
161 return mmap64(start, len, prot, flags, fd, offset);
163 return mmap(start, len, prot, flags, fd, offset);
168 char *d_name(struct dirent *di)
170 #if HAVE_BROKEN_READDIR
171 return (di->d_name - 2);