Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
authorDerrell Lipman <derrell.lipman@unwireduniverse.com>
Thu, 17 Jan 2008 14:29:52 +0000 (09:29 -0500)
committerDerrell Lipman <derrell.lipman@unwireduniverse.com>
Thu, 17 Jan 2008 14:29:52 +0000 (09:29 -0500)
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source/include/vfs.h
source/include/vfs_macros.h
source/modules/vfs_default.c
source/modules/vfs_tsmsm.c
source/smbd/dosmode.c
source/smbd/trans2.c

index 1c2fc4501183672a18acf9a4c2b677a546f3cade..4a6e6be42fd04b1c40ebd52a42cbf4a162af35e6 100644 (file)
@@ -585,9 +585,9 @@ static bool skel_aio_force(struct vfs_handle_struct *handle, struct files_struct
        return vfswrap_aio_force(NULL, fsp);
 }
 
-static int skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf, bool *offline)
+static bool skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
 {
-       return vfswrap_set_offline(NULL, path, sbuf, offline);
+       return vfswrap_is_offline(NULL, path, sbuf);
 }
 
 static int skel_set_offline(struct vfs_handle_struct *handle, const char *path)
@@ -595,11 +595,6 @@ static int skel_set_offline(struct vfs_handle_struct *handle, const char *path)
        return vfswrap_set_offline(NULL, path);
 }
 
-static bool skel_is_remotestorage(struct vfs_handle_struct *handle, const char *path)
-{
-       return vfswrap_is_remotestorage(NULL, path);
-}
-
 /* VFS operations structure */
 
 static vfs_op_tuple skel_op_tuples[] = {
@@ -724,7 +719,6 @@ static vfs_op_tuple skel_op_tuples[] = {
         /* offline operations */
        {SMB_VFS_OP(skel_is_offline),                   SMB_VFS_OP_IS_OFFLINE,                  SMB_VFS_LAYER_OPAQUE},
        {SMB_VFS_OP(skel_set_offline),                  SMB_VFS_OP_SET_OFFLINE,                 SMB_VFS_LAYER_OPAQUE},
-       {SMB_VFS_OP(skel_is_remotestorage),             SMB_VFS_OP_IS_REMOTESTORAGE,            SMB_VFS_LAYER_OPAQUE},
 
        {NULL,                                          SMB_VFS_OP_NOOP,                        SMB_VFS_LAYER_NOOP}
 };
index 0a934976c45db85aa74567aff404a3d7e73b1390..f4cb9b15ba2e048dfa7523e6c54ba707e1f03fc7 100644 (file)
@@ -544,9 +544,9 @@ static bool skel_aio_force(struct vfs_handle_struct *handle, struct files_struct
         return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
 }
 
-static int skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf, bool *offline)
+static bool skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
 {
-       return SMB_VFS_NEXT_IS_OFFLINE(handle, path, sbuf, offline);
+       return SMB_VFS_NEXT_IS_OFFLINE(handle, path, sbuf);
 }
 
 static int skel_set_offline(struct vfs_handle_struct *handle, const char *path)
@@ -681,7 +681,6 @@ static vfs_op_tuple skel_op_tuples[] = {
        /* offline operations */
        {SMB_VFS_OP(skel_is_offline),                   SMB_VFS_OP_IS_OFFLINE,                  SMB_VFS_LAYER_TRANSPARENT},
        {SMB_VFS_OP(skel_set_offline),                  SMB_VFS_OP_SET_OFFLINE,                 SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(skel_is_remotestorage),             SMB_VFS_OP_IS_REMOTESTORAGE,            SMB_VFS_LAYER_TRANSPARENT},
 
        {NULL,                                          SMB_VFS_OP_NOOP,                        SMB_VFS_LAYER_NOOP}
 };
index b0da7e81a5fdf19814b0c28bfdb0eda19ced55f0..d03cf3477dc2202484ff95db2e6f8a5ba7192899 100644 (file)
@@ -261,7 +261,6 @@ typedef enum _vfs_op_type {
        /* offline operations */
        SMB_VFS_OP_IS_OFFLINE,
        SMB_VFS_OP_SET_OFFLINE,
-       SMB_VFS_OP_IS_REMOTESTORAGE,
 
        /* This should always be last enum value */
 
@@ -413,10 +412,8 @@ struct vfs_ops {
                bool (*aio_force)(struct vfs_handle_struct *handle, struct files_struct *fsp);
 
                /* offline operations */
-               int (*is_offline)(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf, bool *offline);
+               bool (*is_offline)(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf);
                int (*set_offline)(struct vfs_handle_struct *handle, const char *path);
-               bool (*is_remotestorage)(struct vfs_handle_struct *handle, const char *path);
-
        } ops;
 
        struct vfs_handles_pointers {
@@ -542,7 +539,6 @@ struct vfs_ops {
                /* offline operations */
                struct vfs_handle_struct *is_offline;
                struct vfs_handle_struct *set_offline;
-               struct vfs_handle_struct *is_remotestorage;
        } handles;
 };
 
index 39f245fa35bcdc80c36bcd9e57dfa55e80026387..dd30f977dc8adb5fbeb65da269e6f21d6b1c3ca9 100644 (file)
 #define SMB_VFS_AIO_FORCE(fsp) ((fsp)->conn->vfs.ops.aio_force((fsp)->conn->vfs.handles.aio_force,(fsp)))
 
 /* Offline operations */
-#define SMB_VFS_IS_OFFLINE(conn,path,sbuf,offline) ((conn)->vfs.ops.is_offline((conn)->vfs.handles.is_offline,(path),(sbuf),(offline)))
+#define SMB_VFS_IS_OFFLINE(conn,path,sbuf) ((conn)->vfs.ops.is_offline((conn)->vfs.handles.is_offline,(path),(sbuf)))
 #define SMB_VFS_SET_OFFLINE(conn,path) ((conn)->vfs.ops.set_offline((conn)->vfs.handles.set_offline,(path)))
-#define SMB_VFS_IS_REMOTESTORAGE(conn,path) ((conn)->vfs.ops.is_remotestorage((conn)->vfs.handles.is_remotestorage,(path)))
 
 /*******************************************************************
  Don't access conn->vfs_opaque.ops directly!!!
 #define SMB_VFS_OPAQUE_AIO_FORCE(fsp) ((fsp)->conn->vfs_opaque.ops.aio_force((fsp)->conn->vfs_opaque.handles.aio_force,(fsp)))
 
 /* Offline operations */
-#define SMB_VFS_OPAQUE_IS_OFFLINE(conn,path,sbuf,offline) ((conn)->vfs_opaque.ops.is_offline((conn)->vfs_opaque.handles.is_offline,(path),(sbuf),(offline)))
+#define SMB_VFS_OPAQUE_IS_OFFLINE(conn,path,sbuf) ((conn)->vfs_opaque.ops.is_offline((conn)->vfs_opaque.handles.is_offline,(path),(sbuf)))
 #define SMB_VFS_OPAQUE_SET_OFFLINE(conn,path) ((conn)->vfs_opaque.ops.set_offline((conn)->vfs_opaque.handles.set_offline,(path)))
-#define SMB_VFS_OPAQUE_IS_REMOTESTORAGE(conn,path) ((conn)->vfs_opaque.ops.is_remotestorage((conn)->vfs_opaque.handles.is_remotestorage,(path)))
 
 /*******************************************************************
  Don't access handle->vfs_next.ops.* directly!!!
 #define SMB_VFS_NEXT_AIO_FORCE(handle,fsp) ((handle)->vfs_next.ops.aio_force((handle)->vfs_next.handles.aio_force,(fsp)))
 
 /* Offline operations */
-#define SMB_VFS_NEXT_IS_OFFLINE(handle,path,sbuf,offline) ((handle)->vfs_next.ops.is_offline((handle)->vfs_next.handles.is_offline,(path),(sbuf),(offline)))
+#define SMB_VFS_NEXT_IS_OFFLINE(handle,path,sbuf) ((handle)->vfs_next.ops.is_offline((handle)->vfs_next.handles.is_offline,(path),(sbuf)))
 #define SMB_VFS_NEXT_SET_OFFLINE(handle,path) ((handle)->vfs_next.ops.set_offline((handle)->vfs_next.handles.set_offline,(path)))
-#define SMB_VFS_NEXT_IS_REMOTESTORAGE(handle,path) ((handle)->vfs_next.ops.is_remotestorage((handle)->vfs_next.handles.is_remotestorage,(path)))
 
 #endif /* _VFS_MACROS_H */
index d4ba4dc6117483d151a1db10b9bc13e50f7da89e..31234f23ecfc86b2edf66d9e62e69bfb216410b8 100644 (file)
@@ -1230,22 +1230,20 @@ static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_str
        return false;
 }
 
-static int vfswrap_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf, bool *offline)
+static bool vfswrap_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
 {
        if (ISDOT(path) || ISDOTDOT(path)) {
-               *offline = false;
-               return 0;
+               return false;
        }
 
        if (!lp_dmapi_support(SNUM(handle->conn)) || !dmapi_have_session()) {
 #if defined(ENOTSUP)
                errno = ENOTSUP;
 #endif
-               return -1;
+               return false;
        }
 
-       *offline = (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0;
-       return 0;
+       return (dmapi_file_flags(path) & FILE_ATTRIBUTE_OFFLINE) != 0;
 }
 
 static int vfswrap_set_offline(struct vfs_handle_struct *handle, const char *path)
@@ -1257,13 +1255,6 @@ static int vfswrap_set_offline(struct vfs_handle_struct *handle, const char *pat
        return -1;
 }
 
-static bool vfswrap_is_remotestorage(struct vfs_handle_struct *handle, const char *path)
-{
-       /* We don't know how to detect that volume is remote storage. VFS modules should redefine it. */
-       return false;
-}
-
-
 static vfs_op_tuple vfs_default_ops[] = {
 
        /* Disk operations */
@@ -1488,8 +1479,6 @@ static vfs_op_tuple vfs_default_ops[] = {
         SMB_VFS_LAYER_OPAQUE},
        {SMB_VFS_OP(vfswrap_set_offline),SMB_VFS_OP_SET_OFFLINE,
         SMB_VFS_LAYER_OPAQUE},
-       {SMB_VFS_OP(vfswrap_is_remotestorage),SMB_VFS_OP_IS_REMOTESTORAGE,
-        SMB_VFS_LAYER_OPAQUE},
 
        /* Finish VFS operations definition */
 
index fe791b24bf91be8524665d32f0caff7805a6456a..2805488e8b5c3b33d001a38a48154fd42c21fef0 100644 (file)
@@ -136,25 +136,23 @@ static int tsmsm_connect(struct vfs_handle_struct *handle,
         return SMB_VFS_NEXT_CONNECT(handle, service, user); 
 }
 
-static int tsmsm_is_offline(struct vfs_handle_struct *handle, 
-                           struct connection_struct *conn,
+static bool tsmsm_is_offline(struct vfs_handle_struct *handle, 
                            const char *path,
-                           SMB_STRUCT_STAT *stbuf,
-                           bool *offline) {
+                           SMB_STRUCT_STAT *stbuf) {
        struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data;
        void *dmhandle = NULL;
        size_t dmhandle_len = 0;
        size_t rlen;
        dm_attrname_t dmname;
        int ret;
+       bool offline;
 
         /* if the file has more than FILE_IS_ONLINE_RATIO of blocks available,
           then assume it is not offline (it may not be 100%, as it could be sparse) */
        if (512 * (off_t)stbuf->st_blocks >= stbuf->st_size * tsmd->online_ratio) {
-               *offline = false;
                DEBUG(10,("%s not offline: st_blocks=%ld st_size=%ld online_ratio=%.2f\n", 
                          path, stbuf->st_blocks, stbuf->st_size, tsmd->online_ratio));
-               return 0;
+               return false;
        }
        
         /* using POSIX capabilities does not work here. It's a slow path, so 
@@ -168,10 +166,9 @@ static int tsmsm_is_offline(struct vfs_handle_struct *handle,
 
        /* go the slow DMAPI route */
        if (dm_path_to_handle((char*)path, &dmhandle, &dmhandle_len) != 0) {
-               ret = -1;
                DEBUG(2,("dm_path_to_handle failed - assuming offline (%s) - %s\n", 
                         path, strerror(errno)));
-               *offline = True;
+               offline = true;
                goto done;
        }
 
@@ -182,7 +179,7 @@ static int tsmsm_is_offline(struct vfs_handle_struct *handle,
                            DM_NO_TOKEN, &dmname, 0, NULL, &rlen);
 
        /* its offline if the IBMObj attribute exists */
-       *offline = (ret == 0 || (ret == -1 && errno == E2BIG));
+       offline = (ret == 0 || (ret == -1 && errno == E2BIG));
 
        DEBUG(10,("dm_get_dmattr %s ret=%d (%s)\n", path, ret, strerror(errno)));
 
@@ -192,7 +189,7 @@ static int tsmsm_is_offline(struct vfs_handle_struct *handle,
 
 done:
        unbecome_root();
-       return ret;
+       return offline;
 }
 
 
@@ -210,7 +207,7 @@ static bool tsmsm_aio_force(struct vfs_handle_struct *handle, struct files_struc
                          sbuf.st_blocks, sbuf.st_size, tsmd->online_ratio));
                return !(512 * (off_t)sbuf.st_blocks >= sbuf.st_size * tsmd->online_ratio);
        }
-       return False;
+       return false;
 }
 
 static ssize_t tsmsm_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, 
@@ -277,7 +274,7 @@ static ssize_t tsmsm_pwrite(struct vfs_handle_struct *handle, struct files_struc
        return result;
 }
 
-static int tsmsm_set_offline(struct vfs_handle_struct *handle, struct connection_struct *conn, 
+static int tsmsm_set_offline(struct vfs_handle_struct *handle, 
                             const char *path) {
        struct tsmsm_struct *tsmd = (struct tsmsm_struct *) handle->data;
        int result = 0;
@@ -297,8 +294,14 @@ static int tsmsm_set_offline(struct vfs_handle_struct *handle, struct connection
        return result;
 }
 
-static bool tsmsm_is_remotestorage(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path) {
-       return True;
+static bool tsmsm_statvfs(struct vfs_handle_struct *handle,  const char *path, vfs_statvfs_struct *statbuf)
+{
+       bool result;
+
+       result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
+       statbuf->FsCapabilities | = FILE_SUPPORTS_REMOTE_STORAGE | FILE_SUPPORTS_REPARSE_POINTS;
+
+       return result;
 }
 
 static vfs_op_tuple vfs_tsmsm_ops[] = {
@@ -307,6 +310,8 @@ static vfs_op_tuple vfs_tsmsm_ops[] = {
 
        {SMB_VFS_OP(tsmsm_connect),     SMB_VFS_OP_CONNECT,
         SMB_VFS_LAYER_TRANSPARENT},
+       {SMB_VFS_OP(tsmsm_statvfs),     SMB_VFS_OP_STATVFS,
+        SMB_VFS_LAYER_TRANSPARENT},
        {SMB_VFS_OP(tsmsm_aio_force),   SMB_VFS_OP_AIO_FORCE,
         SMB_VFS_LAYER_TRANSPARENT},
        {SMB_VFS_OP(tsmsm_aio_return),  SMB_VFS_OP_AIO_RETURN,
@@ -317,11 +322,9 @@ static vfs_op_tuple vfs_tsmsm_ops[] = {
         SMB_VFS_LAYER_TRANSPARENT},
        {SMB_VFS_OP(tsmsm_sendfile),    SMB_VFS_OP_SENDFILE,
         SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(tsmsm_is_offline),SMB_VFS_OP_IS_OFFLINE,
-        SMB_VFS_LAYER_OPAQUE},
-       {SMB_VFS_OP(tsmsm_set_offline),SMB_VFS_OP_SET_OFFLINE,
+       {SMB_VFS_OP(tsmsm_is_offline),  SMB_VFS_OP_IS_OFFLINE,
         SMB_VFS_LAYER_OPAQUE},
-       {SMB_VFS_OP(tsmsm_is_remotestorage),SMB_VFS_OP_IS_REMOTESTORAGE,
+       {SMB_VFS_OP(tsmsm_set_offline), SMB_VFS_OP_SET_OFFLINE,
         SMB_VFS_LAYER_OPAQUE},
 
        /* Finish VFS operations definition */
index 2021621dfa0c94e54b74410af85c8d61184c08e1..eb18f65fca9dc4541925294778c758d9e361ad24 100644 (file)
@@ -350,7 +350,6 @@ uint32 dos_mode(connection_struct *conn, const char *path,SMB_STRUCT_STAT *sbuf)
 {
        uint32 result = 0;
        bool offline;
-       int ret;
 
        DEBUG(8,("dos_mode: %s\n", path));
 
@@ -381,8 +380,8 @@ uint32 dos_mode(connection_struct *conn, const char *path,SMB_STRUCT_STAT *sbuf)
        }
 
        
-       ret = SMB_VFS_IS_OFFLINE(conn, path, sbuf, &offline);
-       if (S_ISREG(sbuf->st_mode) && (ret == 0) && offline) {
+       offline = SMB_VFS_IS_OFFLINE(conn, path, sbuf);
+       if (S_ISREG(sbuf->st_mode) && offline) {
                result |= FILE_ATTRIBUTE_OFFLINE;
        }
 
index 5729ab534997850fd69a3d7c7cdd3b660a6d35f3..23d6f129969e34517efcebd732a8eb980610abcc 100644 (file)
@@ -2495,12 +2495,10 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_dev, (unsi
                        if(lp_nt_acl_support(SNUM(conn))) {
                                additional_flags |= FILE_PERSISTENT_ACLS;
                        }
-                       
-                       if(SMB_VFS_IS_REMOTESTORAGE(conn, lp_pathname(SNUM(conn)))) {
-                               additional_flags |= FILE_SUPPORTS_REMOTE_STORAGE;
-                               additional_flags |= FILE_SUPPORTS_REPARSE_POINTS;
-                       }
-                       
+
+                       /* Capabilities are filled in at connection time through STATVFS call */
+                       additional_flags |= conn->fs_capabilities;
+
                        SIVAL(pdata,0,FILE_CASE_PRESERVED_NAMES|FILE_CASE_SENSITIVE_SEARCH|
                                FILE_SUPPORTS_OBJECT_IDS|FILE_UNICODE_ON_DISK|
                                additional_flags); /* FS ATTRIBUTES */