1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +03:00

r7452: Set sparse flag if needed. Based on code from jpeach@sgi.com.

Fixes bug #2774.
Jeremy.
(This used to be commit 5d366047de)
This commit is contained in:
Jeremy Allison
2005-06-10 00:31:59 +00:00
committed by Gerald (Jerry) Carter
parent 958624a9fc
commit 6d39f3bdce

View File

@ -20,6 +20,16 @@
#include "includes.h" #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. Change a dos mode to a unix mode.
Base permission for files: 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)) if (S_ISDIR(sbuf->st_mode))
result = aDIR | (result & aRONLY); result = aDIR | (result & aRONLY);
#if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE) result |= set_sparse_flag(sbuf);
if (sbuf->st_size > sbuf->st_blocks * (SMB_OFF_T)STAT_ST_BLOCKSIZE) {
result |= FILE_ATTRIBUTE_SPARSE;
}
#endif
#ifdef S_ISLNK #ifdef S_ISLNK
#if LINKS_READ_ONLY #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. */ /* Get the DOS attributes from an EA by preference. */
if (get_ea_dos_attribute(conn, path, sbuf, &result)) { if (get_ea_dos_attribute(conn, path, sbuf, &result)) {
result |= set_sparse_flag(sbuf);
return result; return result;
} }