summaryrefslogtreecommitdiff
path: root/source3/smbd/dosmode.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-05-14 15:34:42 +0200
committerVolker Lendecke <vl@samba.org>2009-05-26 17:48:23 +0200
commit49ca690b4b22ee6e597179059c9442e94c5bd423 (patch)
treead233a9bcfee2d467824290448ca366219dbd301 /source3/smbd/dosmode.c
parent52f2f9449f8d53aa9181d656a4b54a007c80fa81 (diff)
downloadsamba-49ca690b4b22ee6e597179059c9442e94c5bd423.tar.gz
samba-49ca690b4b22ee6e597179059c9442e94c5bd423.tar.bz2
samba-49ca690b4b22ee6e597179059c9442e94c5bd423.zip
Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STAT
This patch introduces struct stat_ex { dev_t st_ex_dev; ino_t st_ex_ino; mode_t st_ex_mode; nlink_t st_ex_nlink; uid_t st_ex_uid; gid_t st_ex_gid; dev_t st_ex_rdev; off_t st_ex_size; struct timespec st_ex_atime; struct timespec st_ex_mtime; struct timespec st_ex_ctime; struct timespec st_ex_btime; /* birthtime */ blksize_t st_ex_blksize; blkcnt_t st_ex_blocks; }; typedef struct stat_ex SMB_STRUCT_STAT; It is really large because due to the friendly libc headers playing macro tricks with fields like st_ino, so I renamed them to st_ex_xxx. Why this change? To support birthtime, we already have quite a few #ifdef's at places where it does not really belong. With a stat struct that we control, we can consolidate the nanosecond timestamps and the birthtime deep in the VFS stat calls. At this moment it is triggered by a request to support the birthtime field for GPFS. GPFS does not extend the system level struct stat, but instead has a separate call that gets us the additional information beyond posix. Without being able to do that within the VFS stat calls, that support would have to be scattered around the main smbd code. It will very likely break all the onefs modules, but I think the changes will be reasonably easy to do.
Diffstat (limited to 'source3/smbd/dosmode.c')
-rw-r--r--source3/smbd/dosmode.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 5ae7151303..9a3470312f 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -23,7 +23,7 @@
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) {
+ if (sbuf->st_ex_size > sbuf->st_ex_blocks * (SMB_OFF_T)STAT_ST_BLOCKSIZE) {
return FILE_ATTRIBUTE_SPARSE;
}
#endif
@@ -88,7 +88,7 @@ mode_t unix_mode(connection_struct *conn, int dosmode, const char *fname,
}
/* Save for later - but explicitly remove setuid bit for safety. */
- dir_mode = sbuf.st_mode & ~S_ISUID;
+ dir_mode = sbuf.st_ex_mode & ~S_ISUID;
DEBUG(2,("unix_mode(%s) inherit mode %o\n",fname,(int)dir_mode));
/* Clear "result" */
result = 0;
@@ -147,7 +147,7 @@ static uint32 dos_mode_from_sbuf(connection_struct *conn, const char *path, SMB_
if (ro_opts == MAP_READONLY_YES) {
/* Original Samba method - map inverse of user "w" bit. */
- if ((sbuf->st_mode & S_IWUSR) == 0) {
+ if ((sbuf->st_ex_mode & S_IWUSR) == 0) {
result |= aRONLY;
}
} else if (ro_opts == MAP_READONLY_PERMISSIONS) {
@@ -157,16 +157,16 @@ static uint32 dos_mode_from_sbuf(connection_struct *conn, const char *path, SMB_
}
} /* Else never set the readonly bit. */
- if (MAP_ARCHIVE(conn) && ((sbuf->st_mode & S_IXUSR) != 0))
+ if (MAP_ARCHIVE(conn) && ((sbuf->st_ex_mode & S_IXUSR) != 0))
result |= aARCH;
- if (MAP_SYSTEM(conn) && ((sbuf->st_mode & S_IXGRP) != 0))
+ if (MAP_SYSTEM(conn) && ((sbuf->st_ex_mode & S_IXGRP) != 0))
result |= aSYSTEM;
- if (MAP_HIDDEN(conn) && ((sbuf->st_mode & S_IXOTH) != 0))
+ if (MAP_HIDDEN(conn) && ((sbuf->st_ex_mode & S_IXOTH) != 0))
result |= aHIDDEN;
- if (S_ISDIR(sbuf->st_mode))
+ if (S_ISDIR(sbuf->st_ex_mode))
result = aDIR | (result & aRONLY);
result |= set_sparse_flag(sbuf);
@@ -225,7 +225,7 @@ static bool get_ea_dos_attribute(connection_struct *conn, const char *path,SMB_S
return False;
}
- if (S_ISDIR(sbuf->st_mode)) {
+ if (S_ISDIR(sbuf->st_ex_mode)) {
dosattr |= aDIR;
}
*pattr = (uint32)(dosattr & SAMBA_ATTRIBUTES_MASK);
@@ -406,7 +406,7 @@ static bool get_stat_dos_flags(connection_struct *conn,
*dosmode |= aSYSTEM;
if (sbuf->st_flags & UF_DOS_NOINDEX)
*dosmode |= FILE_ATTRIBUTE_NONINDEXED;
- if (S_ISDIR(sbuf->st_mode))
+ if (S_ISDIR(sbuf->st_ex_mode))
*dosmode |= aDIR;
*dosmode |= set_sparse_flag(sbuf);
@@ -508,7 +508,7 @@ uint32 dos_mode(connection_struct *conn, const char *path,SMB_STRUCT_STAT *sbuf)
offline = SMB_VFS_IS_OFFLINE(conn, path, sbuf);
- if (S_ISREG(sbuf->st_mode) && offline) {
+ if (S_ISREG(sbuf->st_ex_mode) && offline) {
result |= FILE_ATTRIBUTE_OFFLINE;
}
@@ -563,11 +563,11 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
return(-1);
}
- unixmode = st->st_mode;
+ unixmode = st->st_ex_mode;
- get_acl_group_bits(conn, fname, &st->st_mode);
+ get_acl_group_bits(conn, fname, &st->st_ex_mode);
- if (S_ISDIR(st->st_mode))
+ if (S_ISDIR(st->st_ex_mode))
dosmode |= aDIR;
else
dosmode &= ~aDIR;
@@ -590,7 +590,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
old_mode &= ~FILE_ATTRIBUTE_OFFLINE;
if (old_mode == dosmode) {
- st->st_mode = unixmode;
+ st->st_ex_mode = unixmode;
return(0);
}
@@ -605,7 +605,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
notify_fname(conn, NOTIFY_ACTION_MODIFIED,
FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
}
- st->st_mode = unixmode;
+ st->st_ex_mode = unixmode;
return 0;
}
}
@@ -617,7 +617,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
notify_fname(conn, NOTIFY_ACTION_MODIFIED,
FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
}
- st->st_mode = unixmode;
+ st->st_ex_mode = unixmode;
return 0;
}
@@ -639,10 +639,10 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
if (!MAP_HIDDEN(conn))
mask |= S_IXOTH;
- unixmode |= (st->st_mode & mask);
+ unixmode |= (st->st_ex_mode & mask);
/* if we previously had any r bits set then leave them alone */
- if ((tmp = st->st_mode & (S_IRUSR|S_IRGRP|S_IROTH))) {
+ if ((tmp = st->st_ex_mode & (S_IRUSR|S_IRGRP|S_IROTH))) {
unixmode &= ~(S_IRUSR|S_IRGRP|S_IROTH);
unixmode |= tmp;
}
@@ -650,7 +650,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
/* if we previously had any w bits set then leave them alone
whilst adding in the new w bits, if the new mode is not rdonly */
if (!IS_DOS_READONLY(dosmode)) {
- unixmode |= (st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH));
+ unixmode |= (st->st_ex_mode & (S_IWUSR|S_IWGRP|S_IWOTH));
}
ret = SMB_VFS_CHMOD(conn, fname, unixmode);
@@ -659,7 +659,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
notify_fname(conn, NOTIFY_ACTION_MODIFIED,
FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
}
- st->st_mode = unixmode;
+ st->st_ex_mode = unixmode;
return 0;
}
@@ -696,7 +696,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
}
if (ret == 0) {
- st->st_mode = unixmode;
+ st->st_ex_mode = unixmode;
}
}