summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorBjörn Baumbach <bb@sernet.de>2014-03-27 11:17:30 +0100
committerKarolin Seeger <kseeger@samba.org>2014-09-01 21:34:11 +0200
commit3e6e260cef8182df1aaefaf09a4d6b064ea6e501 (patch)
treed45436eea0f34f6ac6f688ab7f4ac4566b95c940 /source3
parent834d1f653fefa62ad212ee70c7cf793d17fb720b (diff)
downloadsamba-3e6e260cef8182df1aaefaf09a4d6b064ea6e501.tar.gz
s3: enforce a positive allocation_file_size for non-empty files (bug #10543)
Some file systems do not allocate a block for very small files. But for non-empty file should report a positive size. Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Apr 5 03:09:00 CEST 2014 on sn-devel-104 (cherry picked from commit c35b31f45244a8339684c3b83a7d86eefb80e0da)
Diffstat (limited to 'source3')
-rw-r--r--source3/modules/vfs_default.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 7fda4b8227..ed14c673b5 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1530,6 +1530,18 @@ static uint64_t vfswrap_get_alloc_size(vfs_handle_struct *handle,
#else
#error SIZEOF_BLKCNT_T_NOT_A_SUPPORTED_VALUE
#endif
+ if (result == 0) {
+ /*
+ * Some file systems do not allocate a block for very
+ * small files. But for non-empty file should report a
+ * positive size.
+ */
+
+ uint64_t filesize = get_file_size_stat(sbuf);
+ if (filesize > 0) {
+ result = MIN((uint64_t)STAT_ST_BLOCKSIZE, filesize);
+ }
+ }
#else
result = get_file_size_stat(sbuf);
#endif