From ded8347d6b8aca7fafaeb8fea40b789d6425addd Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 18 Feb 2002 22:44:23 +0000 Subject: [PATCH] Cope with BSD systems on which mkdir() will not accept a trailing slash. --- NEWS | 3 +++ syscall.c | 25 ++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 3457da16..8e76d349 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,9 @@ rsync 2.5.3 (not released yet) * Fix for rsync server processes hanging around after the client unexpectedly disconnects. (Colin Walters) (Debian bug #128632) + * Cope with BSD systems on which mkdir() will not accept a trailing + slash. + ENHANCEMENTS: * Command to initiate connections is only shown with -vv, rather diff --git a/syscall.c b/syscall.c index dbac7dc9..f7ce3f03 100644 --- a/syscall.c +++ b/syscall.c @@ -1,5 +1,6 @@ /* Copyright (C) Andrew Tridgell 1998 + Copyright (C) 2002 by Martin Pool This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,9 +17,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* - syscall wrappers to ensure that nothing gets done in dry_run mode - */ +/** + * @file syscall.c + * + * Syscall wrappers to ensure that nothing gets done in dry_run mode + * and to handle system peculiarities. + **/ #include "rsync.h" @@ -106,13 +110,24 @@ int do_rename(char *fname1, char *fname2) return rename(fname1, fname2); } + int do_mkdir(char *fname, mode_t mode) { - if (dry_run) return 0; - CHECK_RO + int l; + if (dry_run) + return 0; + CHECK_RO; + + /* Some BSD systems cannot make a directory if the name + * contains a trailing slash. + * */ + if ((l = strlen(fname)) && (fname[l-1] == '/')) + fname[l-1] = '/'; + return mkdir(fname, mode); } + /* like mkstemp but forces permissions */ int do_mkstemp(char *template, mode_t perms) { -- 2.34.1