Commit | Line | Data |
---|---|---|
31e12522 AT |
1 | /* |
2 | Copyright (C) Andrew Tridgell 1998 | |
3 | ||
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. | |
8 | ||
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. | |
13 | ||
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. | |
17 | */ | |
18 | ||
19 | /* | |
20 | syscall wrappers to ensure that nothing gets done in dry_run mode | |
21 | */ | |
22 | ||
23 | #include "rsync.h" | |
24 | ||
25 | extern int dry_run; | |
26 | ||
27 | int do_unlink(char *fname) | |
28 | { | |
29 | if (dry_run) return 0; | |
30 | return unlink(fname); | |
31 | } | |
32 | ||
33 | int do_symlink(char *fname1, char *fname2) | |
34 | { | |
35 | if (dry_run) return 0; | |
36 | return symlink(fname1, fname2); | |
37 | } | |
38 | ||
f92ef572 | 39 | #if HAVE_LINK |
31e12522 AT |
40 | int do_link(char *fname1, char *fname2) |
41 | { | |
42 | if (dry_run) return 0; | |
43 | return link(fname1, fname2); | |
44 | } | |
f92ef572 | 45 | #endif |
31e12522 | 46 | |
7308bd66 AT |
47 | int do_lchown(const char *path, uid_t owner, gid_t group) |
48 | { | |
49 | if (dry_run) return 0; | |
50 | return lchown(path, owner, group); | |
51 | } | |
52 | ||
f92ef572 | 53 | #if HAVE_MKNOD |
31e12522 AT |
54 | int do_mknod(char *pathname, mode_t mode, dev_t dev) |
55 | { | |
56 | if (dry_run) return 0; | |
57 | return mknod(pathname, mode, dev); | |
58 | } | |
f92ef572 | 59 | #endif |
31e12522 AT |
60 | |
61 | int do_rmdir(char *pathname) | |
62 | { | |
63 | if (dry_run) return 0; | |
64 | return rmdir(pathname); | |
65 | } | |
66 | ||
67 | int do_open(char *pathname, int flags, mode_t mode) | |
68 | { | |
69 | if (dry_run) return -1; | |
70 | return open(pathname, flags, mode); | |
71 | } | |
7308bd66 | 72 | |
f92ef572 | 73 | #if HAVE_CHMOD |
7308bd66 AT |
74 | int do_chmod(const char *path, mode_t mode) |
75 | { | |
76 | if (dry_run) return 0; | |
77 | return chmod(path, mode); | |
78 | } | |
f92ef572 | 79 | #endif |
1b2d733a AT |
80 | |
81 | int do_rename(char *fname1, char *fname2) | |
82 | { | |
83 | if (dry_run) return 0; | |
84 | return rename(fname1, fname2); | |
85 | } | |
86 | ||
87 | int do_mkdir(char *fname, mode_t mode) | |
88 | { | |
89 | if (dry_run) return 0; | |
90 | return mkdir(fname, mode); | |
91 | } | |
92 | ||
93 | char *do_mktemp(char *template) | |
94 | { | |
95 | if (dry_run) return NULL; | |
96 | return mktemp(template); | |
97 | } | |
bcacc18b AT |
98 | |
99 | int do_stat(const char *fname, STRUCT_STAT *st) | |
100 | { | |
101 | #if HAVE_OFF64_T | |
102 | return stat64(fname, st); | |
103 | #else | |
104 | return stat(fname, st); | |
105 | #endif | |
106 | } | |
107 | ||
efb2f6bf | 108 | #if SUPPORT_LINKS |
bcacc18b AT |
109 | int do_lstat(const char *fname, STRUCT_STAT *st) |
110 | { | |
111 | #if HAVE_OFF64_T | |
112 | return lstat64(fname, st); | |
113 | #else | |
114 | return lstat(fname, st); | |
115 | #endif | |
116 | } | |
efb2f6bf | 117 | #endif |
bcacc18b AT |
118 | |
119 | int do_fstat(int fd, STRUCT_STAT *st) | |
120 | { | |
121 | #if HAVE_OFF64_T | |
122 | return fstat64(fd, st); | |
123 | #else | |
124 | return fstat(fd, st); | |
125 | #endif | |
126 | } | |
73233f0f AT |
127 | |
128 | OFF_T do_lseek(int fd, OFF_T offset, int whence) | |
129 | { | |
130 | #if HAVE_OFF64_T | |
131 | return lseek64(fd, offset, whence); | |
132 | #else | |
133 | return lseek(fd, offset, whence); | |
134 | #endif | |
135 | } | |
d6e6ecbd AT |
136 | |
137 | char *d_name(struct dirent *di) | |
138 | { | |
59503278 AT |
139 | #if HAVE_BROKEN_READDIR |
140 | return (di->d_name - 2); | |
141 | #else | |
d6e6ecbd | 142 | return di->d_name; |
59503278 | 143 | #endif |
d6e6ecbd | 144 | } |