s3-smb Use FILE_ATTRIBUTE_READONLY intead of aRONLY
authorAndrew Bartlett <abartlet@samba.org>
Fri, 29 Apr 2011 01:36:14 +0000 (11:36 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 29 Apr 2011 06:38:12 +0000 (16:38 +1000)
This means we use just one constant for this file attribute.

Andrew Bartlett

source3/client/clitar.c
source3/include/smb.h
source3/include/smb_macros.h
source3/lib/util.c
source3/libsmb/libsmb_dir.c
source3/locking/locking.c
source3/smbd/dir.c
source3/smbd/dosmode.c
source3/smbd/reply.c
source3/torture/torture.c

index 645899a9ffb16a8bc01bb3ff1243632b2d5ca079..c29c084cce5aa6cfd0e50cc4d69fd563aaec1469 100644 (file)
@@ -1405,7 +1405,7 @@ int cmd_setmode(void)
                                        direct=0;
                                        break;
                                case 'r':
-                                       attra[direct]|=aRONLY;
+                                       attra[direct]|=FILE_ATTRIBUTE_READONLY;
                                        break;
                                case 'h':
                                        attra[direct]|=aHIDDEN;
index 01866e2e8ac31611e67aad70d40e9641f86c54f4..61a2602fa5c0d68e7522235b2d31bbf51a730309 100644 (file)
@@ -86,7 +86,6 @@ enum smb_read_errors {
 #define DIR_STRUCT_SIZE 43
 
 /* these define the attribute byte as seen by DOS */
-#define aRONLY (1L<<0)         /* 0x01 */
 #define aHIDDEN (1L<<1)                /* 0x02 */
 #define aSYSTEM (1L<<2)                /* 0x04 */
 #define aVOLID (1L<<3)         /* 0x08 */
index 93bda975bf9a369e403644c96823326e6b444948..e4dda7cb93898a4e5b387fe6408f5fb346494937 100644 (file)
@@ -28,7 +28,7 @@
 #define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
 
 /* for readability... */
-#define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0)
+#define IS_DOS_READONLY(test_mode) (((test_mode) & FILE_ATTRIBUTE_READONLY) != 0)
 #define IS_DOS_DIR(test_mode)      (((test_mode) & aDIR) != 0)
 #define IS_DOS_ARCHIVE(test_mode)  (((test_mode) & aARCH) != 0)
 #define IS_DOS_SYSTEM(test_mode)   (((test_mode) & aSYSTEM) != 0)
index 0bb46db05f65b50227750fc7b828223fc26e1c0f..b71be79f06a81664aeaefd105c0978e02e687905 100644 (file)
@@ -309,7 +309,7 @@ char *attrib_string(uint16 mode)
        if (mode & aARCH) fstrcat(attrstr,"A");
        if (mode & aHIDDEN) fstrcat(attrstr,"H");
        if (mode & aSYSTEM) fstrcat(attrstr,"S");
-       if (mode & aRONLY) fstrcat(attrstr,"R");          
+       if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R");
 
        return talloc_strdup(talloc_tos(), attrstr);
 }
index c0c6e83bb63391bc89d9522fcd1c8b60bafb8e85..125bd4e2ef174b10006e3ccaf5a65a26806f3b75 100644 (file)
@@ -1611,7 +1611,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
 
        mode = 0;
 
-       if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= aRONLY;
+       if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= FILE_ATTRIBUTE_READONLY;
        if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= aARCH;
        if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM;
        if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN;
index f5892ddf0d7d431a33a6fa03eab83d257c5e7de7..232a8c37029fb69213c6426c8a1fd73fb7332b79 100644 (file)
@@ -1424,7 +1424,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode)
         * Only allow delete on close for writable files.
         */
 
-       if ((dosmode & aRONLY) &&
+       if ((dosmode & FILE_ATTRIBUTE_READONLY) &&
            !lp_delete_readonly(SNUM(fsp->conn))) {
                DEBUG(10,("can_set_delete_on_close: file %s delete on close "
                          "flag set but file attribute is readonly.\n",
index 5fc87a608fd8857532eccd18a0f51735701542f9..78b16ba468e348365c89d552a9a31efc7d0bccac 100644 (file)
@@ -878,9 +878,9 @@ bool dir_check_ftype(connection_struct *conn, uint32 mode, uint32 dirtype)
        /* Check the "must have" bits, which are the may have bits shifted eight */
        /* If must have bit is set, the file/dir can not be returned in search unless the matching
                file attribute is set */
-       mask = ((dirtype >> 8) & (aDIR|aARCH|aRONLY|aHIDDEN|aSYSTEM)); /* & 0x37 */
+       mask = ((dirtype >> 8) & (aDIR|aARCH|FILE_ATTRIBUTE_READONLY|aHIDDEN|aSYSTEM)); /* & 0x37 */
        if(mask) {
-               if((mask & (mode & (aDIR|aARCH|aRONLY|aHIDDEN|aSYSTEM))) == mask)   /* check if matching attribute present */
+               if((mask & (mode & (aDIR|aARCH|FILE_ATTRIBUTE_READONLY|aHIDDEN|aSYSTEM))) == mask)   /* check if matching attribute present */
                        return True;
                else
                        return False;
index a9b6dfef78e032cd115198abccd0999c1dc6b663..d20d77227a92a6b72ce8f7493371137e1b9f99f0 100644 (file)
@@ -41,7 +41,7 @@ static int set_link_read_only_flag(const SMB_STRUCT_STAT *const sbuf)
 #ifdef S_ISLNK
 #if LINKS_READ_ONLY
        if (S_ISLNK(sbuf->st_mode) && S_ISDIR(sbuf->st_mode))
-               return aRONLY;
+               return FILE_ATTRIBUTE_READONLY;
 #endif
 #endif
        return 0;
@@ -173,12 +173,12 @@ static uint32 dos_mode_from_sbuf(connection_struct *conn,
        if (ro_opts == MAP_READONLY_YES) {
                /* Original Samba method - map inverse of user "w" bit. */
                if ((smb_fname->st.st_ex_mode & S_IWUSR) == 0) {
-                       result |= aRONLY;
+                       result |= FILE_ATTRIBUTE_READONLY;
                }
        } else if (ro_opts == MAP_READONLY_PERMISSIONS) {
                /* Check actual permissions for read-only. */
                if (!can_write_to_file(conn, smb_fname)) {
-                       result |= aRONLY;
+                       result |= FILE_ATTRIBUTE_READONLY;
                }
        } /* Else never set the readonly bit. */
 
@@ -192,14 +192,14 @@ static uint32 dos_mode_from_sbuf(connection_struct *conn,
                result |= aHIDDEN;   
 
        if (S_ISDIR(smb_fname->st.st_ex_mode))
-               result = aDIR | (result & aRONLY);
+               result = aDIR | (result & FILE_ATTRIBUTE_READONLY);
 
        result |= set_link_read_only_flag(&smb_fname->st);
 
        DEBUG(8,("dos_mode_from_sbuf returning "));
 
        if (result & aHIDDEN) DEBUG(8, ("h"));
-       if (result & aRONLY ) DEBUG(8, ("r"));
+       if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
        if (result & aSYSTEM) DEBUG(8, ("s"));
        if (result & aDIR   ) DEBUG(8, ("d"));
        if (result & aARCH  ) DEBUG(8, ("a"));
@@ -326,7 +326,7 @@ static bool get_ea_dos_attribute(connection_struct *conn,
        DEBUG(8,("get_ea_dos_attribute returning (0x%x)", dosattr));
 
        if (dosattr & aHIDDEN) DEBUG(8, ("h"));
-       if (dosattr & aRONLY ) DEBUG(8, ("r"));
+       if (dosattr & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
        if (dosattr & aSYSTEM) DEBUG(8, ("s"));
        if (dosattr & aDIR   ) DEBUG(8, ("d"));
        if (dosattr & aARCH  ) DEBUG(8, ("a"));
@@ -487,7 +487,7 @@ uint32 dos_mode_msdfs(connection_struct *conn,
        DEBUG(8,("dos_mode_msdfs returning "));
 
        if (result & aHIDDEN) DEBUG(8, ("h"));
-       if (result & aRONLY ) DEBUG(8, ("r"));
+       if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
        if (result & aSYSTEM) DEBUG(8, ("s"));
        if (result & aDIR   ) DEBUG(8, ("d"));
        if (result & aARCH  ) DEBUG(8, ("a"));
@@ -511,7 +511,7 @@ int dos_attributes_to_stat_dos_flags(uint32_t dosmode)
                dos_stat_flags |= UF_DOS_ARCHIVE;
        if (dosmode & aHIDDEN)
                dos_stat_flags |= UF_DOS_HIDDEN;
-       if (dosmode & aRONLY)
+       if (dosmode & FILE_ATTRIBUTE_READONLY)
                dos_stat_flags |= UF_DOS_RO;
        if (dosmode & aSYSTEM)
                dos_stat_flags |= UF_DOS_SYSTEM;
@@ -544,7 +544,7 @@ static bool get_stat_dos_flags(connection_struct *conn,
        if (smb_fname->st.st_ex_flags & UF_DOS_HIDDEN)
                *dosmode |= aHIDDEN;
        if (smb_fname->st.st_ex_flags & UF_DOS_RO)
-               *dosmode |= aRONLY;
+               *dosmode |= FILE_ATTRIBUTE_READONLY;
        if (smb_fname->st.st_ex_flags & UF_DOS_SYSTEM)
                *dosmode |= aSYSTEM;
        if (smb_fname->st.st_ex_flags & UF_DOS_NOINDEX)
@@ -672,7 +672,7 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname)
        DEBUG(8,("dos_mode returning "));
 
        if (result & aHIDDEN) DEBUG(8, ("h"));
-       if (result & aRONLY ) DEBUG(8, ("r"));
+       if (result & FILE_ATTRIBUTE_READONLY ) DEBUG(8, ("r"));
        if (result & aSYSTEM) DEBUG(8, ("s"));
        if (result & aDIR   ) DEBUG(8, ("d"));
        if (result & aARCH  ) DEBUG(8, ("a"));
index 01d4332b7e7bf101703f2aad5dd9309bf4b5d17e..8dba6be9435d99c309dca5d305c884731fea0c5f 100644 (file)
@@ -1110,7 +1110,7 @@ void reply_getatr(struct smb_request *req)
        if (*fname == '\0') {
                mode = aHIDDEN | aDIR;
                if (!CAN_WRITE(conn)) {
-                       mode |= aRONLY;
+                       mode |= FILE_ATTRIBUTE_READONLY;
                }
                size = 0;
                mtime = 0;
@@ -2449,10 +2449,10 @@ static NTSTATUS do_unlink(connection_struct *conn,
        fattr = dos_mode(conn, smb_fname);
 
        if (dirtype & FILE_ATTRIBUTE_NORMAL) {
-               dirtype = aDIR|aARCH|aRONLY;
+               dirtype = aDIR|aARCH|FILE_ATTRIBUTE_READONLY;
        }
 
-       dirtype &= (aDIR|aARCH|aRONLY|aHIDDEN|aSYSTEM);
+       dirtype &= (aDIR|aARCH|FILE_ATTRIBUTE_READONLY|aHIDDEN|aSYSTEM);
        if (!dirtype) {
                return NT_STATUS_NO_SUCH_FILE;
        }
index 9fcf582724b59ffbaea21b39c9f1f1697a43819c..0e81f49c71202cbe8158b932726078234aa54d2c 100644 (file)
@@ -4531,7 +4531,7 @@ static bool run_opentest(int dummy)
                return False;
        }
 
-       if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, aRONLY, 0))) {
+       if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, FILE_ATTRIBUTE_READONLY, 0))) {
                printf("cli_setatr failed (%s)\n", cli_errstr(cli1));
                return False;
        }