From 52f5206496b1b8f8dee51f71a3379b2ef256b3ae Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 1 May 2006 23:10:24 +0000 Subject: [PATCH] file_cmds-116.10.tar.gz --- cp/utils.c | 24 ++++++++++++++++++++++++ mv/mv.c | 22 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/cp/utils.c b/cp/utils.c index 707266e..70dc376 100644 --- a/cp/utils.c +++ b/cp/utils.c @@ -58,6 +58,8 @@ __RCSID("$FreeBSD: src/bin/cp/utils.c,v 1.38 2002/07/31 16:52:16 markm Exp $"); #ifdef __APPLE__ #include +#include +#include #endif #include "extern.h" @@ -131,6 +133,28 @@ copy_file(FTSENT *entp, int dne) rval = 0; +#ifdef __APPLE__ + if (S_ISREG(fs->st_mode)) { + struct statfs sfs; + + /* + * Pre-allocate blocks for the destination file if it + * resides on Xsan. + */ + if (fstatfs(to_fd, &sfs) == 0 && + strcmp(sfs.f_fstypename, "acfs") == 0) { + fstore_t fst; + + fst.fst_flags = 0; + fst.fst_posmode = F_PEOFPOSMODE; + fst.fst_offset = 0; + fst.fst_length = fs->st_size; + + (void) fcntl(to_fd, F_PREALLOCATE, &fst); + } + } +#endif /* __APPLE__ */ + /* * Mmap and write if less than 8M (the limit is so we don't totally * trash memory on big files. This is really a minor hack, but it diff --git a/mv/mv.c b/mv/mv.c index f79cc0e..b8f275f 100644 --- a/mv/mv.c +++ b/mv/mv.c @@ -69,6 +69,7 @@ __RCSID("$FreeBSD: src/bin/mv/mv.c,v 1.39 2002/07/09 17:45:13 johan Exp $"); #ifdef __APPLE__ #include +#include #endif #include "pathnames.h" @@ -322,6 +323,27 @@ fastcopy(char *from, char *to, struct stat *sbp) (void)close(from_fd); return (1); } +#ifdef __APPLE__ + { + struct statfs sfs; + + /* + * Pre-allocate blocks for the destination file if it + * resides on Xsan. + */ + if (fstatfs(to_fd, &sfs) == 0 && + strcmp(sfs.f_fstypename, "acfs") == 0) { + fstore_t fst; + + fst.fst_flags = 0; + fst.fst_posmode = F_PEOFPOSMODE; + fst.fst_offset = 0; + fst.fst_length = sbp->st_size; + + (void) fcntl(to_fd, F_PREALLOCATE, &fst); + } + } +#endif /* __APPLE__ */ while ((nread = read(from_fd, bp, (size_t)blen)) > 0) if (write(to_fd, bp, (size_t)nread) != nread) { warn("%s", to); -- 2.7.4