summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-06-10 00:31:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:57:09 -0500
commit6d39f3bdce5ba8ed7d88a430a2de9f96d4b2c513 (patch)
tree10a29f76c34635fa14956d56f4b6189569e13267
parent958624a9fc36f89de1b33ca79b1a72fcb63cbb62 (diff)
downloadsamba-6d39f3bdce5ba8ed7d88a430a2de9f96d4b2c513.tar.gz
samba-6d39f3bdce5ba8ed7d88a430a2de9f96d4b2c513.tar.bz2
samba-6d39f3bdce5ba8ed7d88a430a2de9f96d4b2c513.zip
r7452: Set sparse flag if needed. Based on code from jpeach@sgi.com.
Fixes bug #2774. Jeremy. (This used to be commit 5d366047debed68f36d44d34233ba4670e412d1e)
-rw-r--r--source3/smbd/dosmode.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 65ea2807e7..3602e3f908 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -20,6 +20,16 @@
#include "includes.h"
+static int set_sparse_flag(const SMB_STRUCT_STAT * const sbuf)
+{
+#if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
+ if (sbuf->st_size > sbuf->st_blocks * (SMB_OFF_T)STAT_ST_BLOCKSIZE) {
+ return FILE_ATTRIBUTE_SPARSE;
+ }
+#endif
+ return 0;
+}
+
/****************************************************************************
Change a dos mode to a unix mode.
Base permission for files:
@@ -140,11 +150,7 @@ uint32 dos_mode_from_sbuf(connection_struct *conn, const char *path, SMB_STRUCT_
if (S_ISDIR(sbuf->st_mode))
result = aDIR | (result & aRONLY);
-#if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
- if (sbuf->st_size > sbuf->st_blocks * (SMB_OFF_T)STAT_ST_BLOCKSIZE) {
- result |= FILE_ATTRIBUTE_SPARSE;
- }
-#endif
+ result |= set_sparse_flag(sbuf);
#ifdef S_ISLNK
#if LINKS_READ_ONLY
@@ -293,6 +299,7 @@ uint32 dos_mode(connection_struct *conn, const char *path,SMB_STRUCT_STAT *sbuf)
/* Get the DOS attributes from an EA by preference. */
if (get_ea_dos_attribute(conn, path, sbuf, &result)) {
+ result |= set_sparse_flag(sbuf);
return result;
}