The Samba-Bugzilla – Attachment 7294 Details for
Bug 4621
Option to create ancestors of destination, like "mkdir -p"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
change default creation of directories to work just like "mkdir -p"
0001-BUG4621-create-ancestors-of-destination.patch (text/plain), 1.43 KB, created by
Carlo Marcelo Arenas Belon
on 2012-02-06 06:32:17 UTC
(
hide
)
Description:
change default creation of directories to work just like "mkdir -p"
Filename:
MIME Type:
Creator:
Carlo Marcelo Arenas Belon
Created:
2012-02-06 06:32:17 UTC
Size:
1.43 KB
patch
obsolete
>From e397e5ba0239e145ed0e5b01d0052a464b6af8d6 Mon Sep 17 00:00:00 2001 >From: Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe> >Date: Sun, 5 Feb 2012 22:24:17 -0800 >Subject: [PATCH] BUG4621: create ancestors of destination > >when mkdir fails because the ancestors of a destination directory >are missing, fallback to create all ancestors to try to recover >from such failure. > >this allows a destination directory which is missing its parent >to be used, by letting rsync create those directories as it does >for the last leaf. > >Signed-off-by: Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe> >--- > syscall.c | 25 ++++++++++++++++++++++++- > 1 files changed, 24 insertions(+), 1 deletions(-) > >diff --git a/syscall.c b/syscall.c >index c85f73e..9bd1ec0 100644 >--- a/syscall.c >+++ b/syscall.c >@@ -219,10 +219,33 @@ void trim_trailing_slashes(char *name) > > int do_mkdir(char *fname, mode_t mode) > { >+ int ret; > if (dry_run) return 0; > RETURN_ERROR_IF_RO_OR_LO; > trim_trailing_slashes(fname); >- return mkdir(fname, mode); >+ ret = mkdir(fname, mode); >+ if (ret < 0 && errno == ENOENT) { >+ char *pname, *p, *np; >+ >+ pname = strdup(fname); >+ if (*pname == '/') >+ p = pname + 1; >+ else >+ p = pname; >+ >+ do { >+ np = strchr(p, '/'); >+ if (np) { >+ *np = 0; >+ mkdir(pname, mode); >+ *np = '/'; >+ p = np + 1; >+ } >+ } while (np); >+ ret = mkdir(pname, mode); >+ free(pname); >+ } >+ return ret; > } > > /* like mkstemp but forces permissions */ >-- >1.7.8.4 >
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 4621
: 7294