The Samba-Bugzilla – Attachment 1336 Details for
Bug 2913
rsync of symlinks on >=bsd needs lutimes(2) and lchmod(2)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Use lchmod and lutimes, if present
lchmod-lutimes.patch (text/plain), 4.88 KB, created by
Wayne Davison
on 2005-07-26 09:27:22 UTC
(
hide
)
Description:
Use lchmod and lutimes, if present
Filename:
MIME Type:
Creator:
Wayne Davison
Created:
2005-07-26 09:27:22 UTC
Size:
4.88 KB
patch
obsolete
>--- configure.in 7 Jul 2005 22:53:59 -0000 1.225 >+++ configure.in 26 Jul 2005 16:13:21 -0000 >@@ -496,11 +496,12 @@ dnl AC_FUNC_MEMCMP > > AC_FUNC_UTIME_NULL > AC_FUNC_ALLOCA >-AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo \ >- fchmod fstat strchr readlink link utime utimes strftime mtrace ftruncate \ >+AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \ >+ fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \ > memmove lchown vsnprintf snprintf vasprintf asprintf setsid glob strpbrk \ > strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \ >- setlocale setmode open64 lseek64 mkstemp64 va_copy __va_copy) >+ setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \ >+ strerror) > > AC_CHECK_FUNCS(getpgrp tcgetpgrp) > if test $ac_cv_func_getpgrp = yes; then >--- generator.c 30 Jun 2005 17:03:14 -0000 1.217 >+++ generator.c 26 Jul 2005 16:13:21 -0000 >@@ -1207,17 +1207,19 @@ void generate_files(int f_out, struct fi > /* We need to ensure that any dirs we create have writeable > * permissions during the time we are putting files within > * them. This is then fixed after the transfer is done. */ >+#ifdef HAVE_CHMOD > if (!am_root && S_ISDIR(file->mode) && !(file->mode & S_IWUSR) > && !list_only) { > int mode = file->mode | S_IWUSR; /* user write */ > char *fname = local_name ? local_name : fbuf; >- if (do_chmod(fname, mode & CHMOD_BITS) < 0) { >+ if (do_chmod(fname, mode) < 0) { > rsyserr(FERROR, errno, > "failed to modify permissions on %s", > full_fname(fname)); > } > need_retouch_dir_perms = 1; > } >+#endif > > if (preserve_hard_links) > check_for_finished_hlinks(itemizing, code); >--- rsync.c 14 Mar 2005 17:06:08 -0000 1.167 >+++ rsync.c 26 Jul 2005 16:13:21 -0000 >@@ -68,17 +68,18 @@ int set_perms(char *fname,struct file_st > st = &st2; > } > >- if (!preserve_times || S_ISLNK(st->st_mode) >- || (S_ISDIR(st->st_mode) && omit_dir_times)) >+ if (!preserve_times || (S_ISDIR(st->st_mode) && omit_dir_times)) > flags |= PERMS_SKIP_MTIME; > if (!(flags & PERMS_SKIP_MTIME) > && cmp_modtime(st->st_mtime, file->modtime) != 0) { >- if (set_modtime(fname,file->modtime) != 0) { >+ int ret = set_modtime(fname, file->modtime, st->st_mode); >+ if (ret < 0) { > rsyserr(FERROR, errno, "failed to set times on %s", > full_fname(fname)); > return 0; > } >- updated = 1; >+ if (ret == 0) /* ret == 1 if symlink could not be set */ >+ updated = 1; > } > > change_uid = am_root && preserve_uid && st->st_uid != file->uid; >@@ -125,15 +126,16 @@ int set_perms(char *fname,struct file_st > } > > #ifdef HAVE_CHMOD >- if (!S_ISLNK(st->st_mode)) { >- if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) { >- updated = 1; >- if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) { >- rsyserr(FERROR, errno, "failed to set permissions on %s", >- full_fname(fname)); >- return 0; >- } >+ if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) { >+ int ret = do_chmod(fname, file->mode); >+ if (ret < 0) { >+ rsyserr(FERROR, errno, >+ "failed to set permissions on %s", >+ full_fname(fname)); >+ return 0; > } >+ if (ret == 0) /* ret == 1 if symlink could not be set */ >+ updated = 1; > } > #endif > >--- syscall.c 6 Apr 2005 02:08:21 -0000 1.43 >+++ syscall.c 26 Jul 2005 16:13:21 -0000 >@@ -137,7 +137,14 @@ int do_chmod(const char *path, mode_t mo > 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; >--- util.c 7 Jul 2005 19:49:14 -0000 1.184 >+++ util.c 26 Jul 2005 16:13:22 -0000 >@@ -128,8 +128,13 @@ void overflow_exit(char *str) > > > >-int set_modtime(char *fname, time_t modtime) >+int set_modtime(char *fname, time_t modtime, mode_t mode) > { >+#if !defined HAVE_LUTIMES || !defined HAVE_UTIMES >+ if (S_ISLNK(mode)) >+ return 1; >+#endif >+ > if (verbose > 2) { > rprintf(FINFO, "set modtime of %s to (%ld) %s", > safe_fname(fname), (long)modtime, >@@ -140,7 +145,18 @@ int set_modtime(char *fname, time_t modt > return 0; > > { >-#ifdef HAVE_UTIMBUF >+#ifdef HAVE_UTIMES >+ struct timeval t[2]; >+ t[0].tv_sec = time(NULL); >+ t[0].tv_usec = 0; >+ t[1].tv_sec = modtime; >+ t[1].tv_usec = 0; >+# ifdef HAVE_LUTIMES >+ if (S_ISLNK(mode)) >+ return lutimes(fname, t); >+# endif >+ return utimes(fname, t); >+#elif defined HAVE_UTIMBUF > struct utimbuf tbuf; > tbuf.actime = time(NULL); > tbuf.modtime = modtime; >@@ -151,12 +167,7 @@ int set_modtime(char *fname, time_t modt > t[1] = modtime; > return utime(fname,t); > #else >- struct timeval t[2]; >- t[0].tv_sec = time(NULL); >- t[0].tv_usec = 0; >- t[1].tv_sec = modtime; >- t[1].tv_usec = 0; >- return utimes(fname,t); >+#error No file-time-modification routine found! > #endif > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 2913
: 1336