diff options
author | Alexander Bokovoy <ab@samba.org> | 2008-02-06 09:09:23 +0300 |
---|---|---|
committer | Alexander Bokovoy <ab@samba.org> | 2008-02-06 09:09:23 +0300 |
commit | 1ae0f2d02ea5909fbb8cfa7c0d78291048699b9c (patch) | |
tree | 0569a227641ed271e38737ef62d1d1e7d4316262 /source3 | |
parent | d022ed3eecbe4c3bd0c93ee09608c43048e6881a (diff) | |
download | samba-1ae0f2d02ea5909fbb8cfa7c0d78291048699b9c.tar.gz samba-1ae0f2d02ea5909fbb8cfa7c0d78291048699b9c.tar.bz2 samba-1ae0f2d02ea5909fbb8cfa7c0d78291048699b9c.zip |
Allow actual call to set file offline
Dos mode calculation was masking out FILE_ATTRIBUTE_OFFLINE so that code to set file offline
was never called before. Merge from Tridge's v3-0-ctdb git tree.
(This used to be commit 9827d5ff416479408b19a8964c2321ea2517aa74)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/dosmode.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index eb18f65fca..f068f1f655 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -419,9 +419,10 @@ int file_set_dosmode(connection_struct *conn, const char *fname, mode_t tmp; mode_t unixmode; int ret = -1, lret = -1; + uint32_t old_mode; /* We only allow READONLY|HIDDEN|SYSTEM|DIRECTORY|ARCHIVE here. */ - dosmode &= SAMBA_ATTRIBUTES_MASK; + dosmode &= SAMBA_ATTRIBUTES_MASK | FILE_ATTRIBUTE_OFFLINE; DEBUG(10,("file_set_dosmode: setting dos mode 0x%x on file %s\n", dosmode, fname)); @@ -444,7 +445,24 @@ int file_set_dosmode(connection_struct *conn, const char *fname, else dosmode &= ~aDIR; - if (dos_mode(conn,fname,st) == dosmode) { + old_mode = dos_mode(conn,fname,st); + + if (dosmode & FILE_ATTRIBUTE_OFFLINE) { + if (!(old_mode & FILE_ATTRIBUTE_OFFLINE)) { + lret = SMB_VFS_SET_OFFLINE(conn, fname); + if (lret == -1) { + DEBUG(0, ("set_dos_mode: client has asked to set " + "FILE_ATTRIBUTE_OFFLINE to %s/%s but there was " + "an error while setting it or it is not supported.\n", + parent_dir, fname)); + } + } + } + + dosmode &= ~FILE_ATTRIBUTE_OFFLINE; + old_mode &= ~FILE_ATTRIBUTE_OFFLINE; + + if (old_mode == dosmode) { st->st_mode = unixmode; return(0); } @@ -491,16 +509,6 @@ int file_set_dosmode(connection_struct *conn, const char *fname, unixmode |= (st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)); } - if (dosmode & FILE_ATTRIBUTE_OFFLINE) { - lret = SMB_VFS_SET_OFFLINE(conn, fname); - if (lret == -1) { - DEBUG(0, ("set_dos_mode: client has asked to set " - "FILE_ATTRIBUTE_OFFLINE to %s/%s but there was " - "an error while setting it or it is not supported.\n", - parent_dir, fname)); - } - } - ret = SMB_VFS_CHMOD(conn, fname, unixmode); if (ret == 0) { if(!newfile || (lret != -1)) { |