added chmod() and chown() to syscall.c
authorAndrew Tridgell <tridge@samba.org>
Tue, 24 Mar 1998 06:39:16 +0000 (06:39 +0000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 24 Mar 1998 06:39:16 +0000 (06:39 +0000)
rsync.c
syscall.c

diff --git a/rsync.c b/rsync.c
index 1be378f..4560455 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -223,7 +223,7 @@ static int set_perms(char *fname,struct file_struct *file,struct stat *st,
   if (preserve_perms && !S_ISLNK(st->st_mode) &&
       st->st_mode != file->mode) {
     updated = 1;
-    if (chmod(fname,file->mode) != 0) {
+    if (do_chmod(fname,file->mode) != 0) {
       fprintf(FERROR,"failed to set permissions on %s : %s\n",
              fname,strerror(errno));
       return 0;
@@ -234,7 +234,7 @@ static int set_perms(char *fname,struct file_struct *file,struct stat *st,
   if ((am_root && preserve_uid && st->st_uid != file->uid) || 
       (preserve_gid && st->st_gid != file->gid)) {
     updated = 1;
-    if (lchown(fname,
+    if (do_lchown(fname,
               (am_root&&preserve_uid)?file->uid:-1,
               preserve_gid?file->gid:-1) != 0) {
       if (verbose>1 || preserve_uid)
index d92cb31..8905381 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -42,6 +42,12 @@ int do_link(char *fname1, char *fname2)
        return link(fname1, fname2);
 }
 
+int do_lchown(const char *path, uid_t owner, gid_t group)
+{
+       if (dry_run) return 0;
+       return lchown(path, owner, group);
+}
+
 int do_mknod(char *pathname, mode_t mode, dev_t dev)
 {
        if (dry_run) return 0;
@@ -59,3 +65,9 @@ int do_open(char *pathname, int flags, mode_t mode)
        if (dry_run) return -1;
        return open(pathname, flags, mode);
 }
+
+int do_chmod(const char *path, mode_t mode)
+{
+       if (dry_run) return 0;
+       return chmod(path, mode);
+}