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
28 #define CHECK_RO if (read_only) {errno = EROFS; return -1;}
30 int do_unlink(char *fname)
32 if (dry_run) return 0;
37 int do_symlink(char *fname1, char *fname2)
39 if (dry_run) return 0;
41 return symlink(fname1, fname2);
45 int do_link(char *fname1, char *fname2)
47 if (dry_run) return 0;
49 return link(fname1, fname2);
53 int do_lchown(const char *path, uid_t owner, gid_t group)
55 if (dry_run) return 0;
57 return lchown(path, owner, group);
61 int do_mknod(char *pathname, mode_t mode, dev_t dev)
63 if (dry_run) return 0;
65 return mknod(pathname, mode, dev);
69 int do_rmdir(char *pathname)
71 if (dry_run) return 0;
73 return rmdir(pathname);
76 int do_open(char *pathname, int flags, mode_t mode)
78 if (dry_run) return -1;
84 return open(pathname, flags, mode);
88 int do_chmod(const char *path, mode_t mode)
90 if (dry_run) return 0;
92 return chmod(path, mode);
96 int do_rename(char *fname1, char *fname2)
98 if (dry_run) return 0;
100 return rename(fname1, fname2);
103 int do_mkdir(char *fname, mode_t mode)
105 if (dry_run) return 0;
107 return mkdir(fname, mode);
110 char *do_mktemp(char *template)
112 if (dry_run) return NULL;
113 if (read_only) {errno = EROFS; return NULL;}
114 return mktemp(template);
117 int do_stat(const char *fname, STRUCT_STAT *st)
120 return stat64(fname, st);
122 return stat(fname, st);
127 int do_lstat(const char *fname, STRUCT_STAT *st)
130 return lstat64(fname, st);
132 return lstat(fname, st);
137 int do_fstat(int fd, STRUCT_STAT *st)
140 return fstat64(fd, st);
142 return fstat(fd, st);
146 OFF_T do_lseek(int fd, OFF_T offset, int whence)
150 return lseek64(fd, offset, whence);
152 return lseek(fd, offset, whence);
157 void *do_mmap(void *start, int len, int prot, int flags, int fd, OFF_T offset)
160 return mmap64(start, len, prot, flags, fd, offset);
162 return mmap(start, len, prot, flags, fd, offset);
167 char *d_name(struct dirent *di)
169 #if HAVE_BROKEN_READDIR
170 return (di->d_name - 2);