Changes in samba vxfs plugin.
[samba.git] / source3 / modules / vfs_vxfs.c
index f1f61f18578401e1328639a1a6e08f455c4cf2c1..335fd18d9b990e9b7a1d683ac47249370f07337f 100644 (file)
@@ -828,6 +828,93 @@ static ssize_t vxfs_flistxattr(struct vfs_handle_struct *handle,
         return result;
 }
 
+static NTSTATUS vxfs_set_ea_dos_attributes(struct vfs_handle_struct *handle,
+                                          const struct smb_filename *smb_fname,
+                                          uint32_t dosmode)
+{
+       NTSTATUS        err;
+       int             ret = 0;
+       bool            attrset = false;
+
+       DBG_DEBUG("Entered function\n");
+
+       if (!(dosmode & FILE_ATTRIBUTE_READONLY)) {
+               ret = vxfs_checkwxattr_path(smb_fname->base_name);
+               if (ret == -1) {
+                       DBG_DEBUG("ret:%d\n", ret);
+                       if ((errno != EOPNOTSUPP) && (errno != ENOENT)) {
+                               return map_nt_error_from_unix(errno);
+                       }
+               }
+       }
+       if (dosmode & FILE_ATTRIBUTE_READONLY) {
+               ret = vxfs_setwxattr_path(smb_fname->base_name);
+               DBG_DEBUG("ret:%d\n", ret);
+               if (ret == -1) {
+                       if ((errno != EOPNOTSUPP) && (errno != EINVAL)) {
+                               return map_nt_error_from_unix(errno);
+                       }
+               } else {
+                       attrset = true;
+               }
+       }
+       err = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle, smb_fname, dosmode);
+       if (!NT_STATUS_IS_OK(err)) {
+               if (attrset) {
+                       ret = vxfs_clearwxattr_path(smb_fname->base_name);
+                       DBG_DEBUG("ret:%d\n", ret);
+                       if ((ret == -1) && (errno != ENOENT)) {
+                               return map_nt_error_from_unix(errno);
+                       }
+               }
+       }
+
+       return err;
+}
+
+static NTSTATUS vxfs_fset_ea_dos_attributes(struct vfs_handle_struct *handle,
+                                           struct files_struct *fsp,
+                                           uint32_t dosmode)
+{
+       NTSTATUS        err;
+       int             ret = 0;
+       bool            attrset = false;
+
+       DBG_DEBUG("Entered function\n");
+
+       if (!(dosmode & FILE_ATTRIBUTE_READONLY)) {
+               ret = vxfs_checkwxattr_fd(fsp->fh->fd);
+               if (ret == -1) {
+                       DBG_DEBUG("ret:%d\n", ret);
+                       if ((errno != EOPNOTSUPP) && (errno != ENOENT)) {
+                               return map_nt_error_from_unix(errno);
+                       }
+               }
+       }
+       if (dosmode & FILE_ATTRIBUTE_READONLY) {
+               ret = vxfs_setwxattr_fd(fsp->fh->fd);
+               DBG_DEBUG("ret:%d\n", ret);
+               if (ret == -1) {
+                       if ((errno != EOPNOTSUPP) && (errno != EINVAL)) {
+                               return map_nt_error_from_unix(errno);
+                       }
+               } else {
+                       attrset = true;
+               }
+       }
+       err = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle, fsp, dosmode);
+       if (!NT_STATUS_IS_OK(err)) {
+               if (attrset) {
+                       ret = vxfs_clearwxattr_fd(fsp->fh->fd);
+                       DBG_DEBUG("ret:%d\n", ret);
+                       if ((ret == -1) && (errno != ENOENT)) {
+                               return map_nt_error_from_unix(errno);
+                       }
+               }
+       }
+       return err;
+}
+
 static int vfs_vxfs_connect(struct vfs_handle_struct *handle,
                            const char *service, const char *user)
 {
@@ -852,6 +939,8 @@ static struct vfs_fn_pointers vfs_vxfs_fns = {
        .sys_acl_set_fd_fn = vxfs_sys_acl_set_fd,
 #endif
 
+       .set_dos_attributes_fn = vxfs_set_ea_dos_attributes,
+       .fset_dos_attributes_fn = vxfs_fset_ea_dos_attributes,
        .getxattr_fn = vxfs_get_xattr,
        .fgetxattr_fn = vxfs_fget_xattr,
        .listxattr_fn = vxfs_listxattr,