Tweaked some whitespace to match the latest version from autoconf.
[rsync/rsync.git] / syscall.c
index 2607774..5cee232 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -45,14 +45,14 @@ extern int preserve_perms;
 
 #define RETURN_ERROR_IF_RO_OR_LO RETURN_ERROR_IF(read_only || list_only, EROFS)
 
-int do_unlink(char *fname)
+int do_unlink(const char *fname)
 {
        if (dry_run) return 0;
        RETURN_ERROR_IF_RO_OR_LO;
        return unlink(fname);
 }
 
-int do_symlink(char *fname1, char *fname2)
+int do_symlink(const char *fname1, const char *fname2)
 {
        if (dry_run) return 0;
        RETURN_ERROR_IF_RO_OR_LO;
@@ -60,7 +60,7 @@ int do_symlink(char *fname1, char *fname2)
 }
 
 #ifdef HAVE_LINK
-int do_link(char *fname1, char *fname2)
+int do_link(const char *fname1, const char *fname2)
 {
        if (dry_run) return 0;
        RETURN_ERROR_IF_RO_OR_LO;
@@ -104,7 +104,11 @@ int do_mknod(char *pathname, mode_t mode, dev_t dev)
                    || (bind(sock, (struct sockaddr*)&saddr, sizeof saddr)) < 0)
                        return -1;
                close(sock);
+#ifdef HAVE_CHMOD
                return do_chmod(pathname, mode);
+#else
+               return 0;
+#endif
        }
 #endif
 #ifdef HAVE_MKNOD
@@ -114,14 +118,14 @@ int do_mknod(char *pathname, mode_t mode, dev_t dev)
 #endif
 }
 
-int do_rmdir(char *pathname)
+int do_rmdir(const char *pathname)
 {
        if (dry_run) return 0;
        RETURN_ERROR_IF_RO_OR_LO;
        return rmdir(pathname);
 }
 
-int do_open(char *pathname, int flags, mode_t mode)
+int do_open(const char *pathname, int flags, mode_t mode)
 {
        if (flags != O_RDONLY) {
                RETURN_ERROR_IF(dry_run, 0);
@@ -137,21 +141,27 @@ int do_chmod(const char *path, mode_t mode)
        int code;
        if (dry_run) return 0;
        RETURN_ERROR_IF_RO_OR_LO;
-       code = chmod(path, mode);
+       if (S_ISLNK(mode)) {
+#ifdef HAVE_LCHMOD
+               code = lchmod(path, mode & CHMOD_BITS);
+#else
+               code = 1;
+#endif
+       } else
+               code = chmod(path, mode & CHMOD_BITS);
        if (code != 0 && preserve_perms)
            return code;
        return 0;
 }
 #endif
 
-int do_rename(char *fname1, char *fname2)
+int do_rename(const char *fname1, const char *fname2)
 {
        if (dry_run) return 0;
        RETURN_ERROR_IF_RO_OR_LO;
        return rename(fname1, fname2);
 }
 
-
 void trim_trailing_slashes(char *name)
 {
        int l;
@@ -170,7 +180,6 @@ void trim_trailing_slashes(char *name)
        }
 }
 
-
 int do_mkdir(char *fname, mode_t mode)
 {
        if (dry_run) return 0;
@@ -179,7 +188,6 @@ int do_mkdir(char *fname, mode_t mode)
        return mkdir(fname, mode);
 }
 
-
 /* like mkstemp but forces permissions */
 int do_mkstemp(char *template, mode_t perms)
 {
@@ -243,8 +251,12 @@ int do_fstat(int fd, STRUCT_STAT *st)
 
 OFF_T do_lseek(int fd, OFF_T offset, int whence)
 {
-#ifdef SIZEOF_OFF64_T
+#ifdef HAVE_LSEEK64
+#if !SIZEOF_OFF64_T
+       OFF_T lseek64();
+#else
        off64_t lseek64();
+#endif
        return lseek64(fd, offset, whence);
 #else
        return lseek(fd, offset, whence);