components/samba/samba/patches/vfs_samfs.c.patch
changeset 923 79e84368f624
parent 628 c3c0c8f3f696
child 1207 1d0be3a9fc06
equal deleted inserted replaced
922:f0a67cc3878c 923:79e84368f624
    37  SMB_MODULE(vfs_acl_xattr, \$(VFS_ACL_XATTR_OBJ), "bin/acl_xattr.$SHLIBEXT", VFS)
    37  SMB_MODULE(vfs_acl_xattr, \$(VFS_ACL_XATTR_OBJ), "bin/acl_xattr.$SHLIBEXT", VFS)
    38  SMB_MODULE(vfs_acl_tdb, \$(VFS_ACL_TDB_OBJ), "bin/acl_tdb.$SHLIBEXT", VFS)
    38  SMB_MODULE(vfs_acl_tdb, \$(VFS_ACL_TDB_OBJ), "bin/acl_tdb.$SHLIBEXT", VFS)
    39 diff --git a/source3/modules/vfs_samfs.c b/source3/modules/vfs_samfs.c
    39 diff --git a/source3/modules/vfs_samfs.c b/source3/modules/vfs_samfs.c
    40 new file mode 100644
    40 new file mode 100644
    41 index 0000000..9370768
    41 index 0000000..9370768
    42 --- /dev/null
    42 --- /dev/null	2012-07-16 09:13:54.000000000 -0700
    43 +++ b/source3/modules/vfs_samfs.c
    43 +++ b/source3/modules/vfs_samfs.c	2012-07-16 09:21:00.168046000 -0700
    44 @@ -0,0 +1,166 @@
    44 @@ -0,0 +1,180 @@
    45 +/*
    45 +/*
    46 + * Support for offline files with Sun SAM-QFS
    46 + * Support for offline files with Sun SAM-QFS
    47 + *
    47 + *
    48 + * Copyright (C) Dirk Nitschke, 2009
    48 + * Copyright (C) Dirk Nitschke, 2009
    49 + *
    49 + *
    89 + *
    89 + *
    90 + * See sam_stat(3) and sam_segment_stat(3) for details.
    90 + * See sam_stat(3) and sam_segment_stat(3) for details.
    91 + *
    91 + *
    92 + * If something goes wrong we assume that the file is offline.
    92 + * If something goes wrong we assume that the file is offline.
    93 + */
    93 + */
    94 +static bool samfs_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
    94 +static bool samfs_is_offline(struct vfs_handle_struct *handle, const struct smb_filename *fname, SMB_STRUCT_STAT *sbuf)
    95 +{
    95 +{
    96 +	struct sam_stat file_info;
    96 +	struct sam_stat file_info;
    97 +	struct sam_stat *seg_info_ptr;
    97 +	struct sam_stat *seg_info_ptr;
    98 +	bool offline;
    98 +	int number_of_segments, number_of_segments_offline = 0;
    99 +	int number_of_segments;
       
   100 +	int result;
    99 +	int result;
   101 +	int i;
   100 +	int i;
   102 +
   101 +	NTSTATUS status;
   103 +	offline = false;
   102 +	char *path;
       
   103 +
       
   104 +        status = get_full_smb_filename(talloc_tos(), fname, &path);
       
   105 +        if (!NT_STATUS_IS_OK(status)) {
       
   106 +                errno = map_errno_from_nt_status(status);
       
   107 +                return false;
       
   108 +        }
       
   109 +
   104 +	if (ISDOT(path) || ISDOTDOT(path)) {
   110 +	if (ISDOT(path) || ISDOTDOT(path)) {
   105 +		return false;
   111 +		return false;
   106 +	}
   112 +	}
   107 +
   113 +
   108 +	/*
   114 +	/*
   159 +		 * Loop over segments until we have checked all segments
   165 +		 * Loop over segments until we have checked all segments
   160 +		 * or found one which is offline.
   166 +		 * or found one which is offline.
   161 +		 */
   167 +		 */
   162 +		for (i = 0; i < number_of_segments; i++) {
   168 +		for (i = 0; i < number_of_segments; i++) {
   163 +			if (SS_ISOFFLINE(seg_info_ptr[i].attr)) {
   169 +			if (SS_ISOFFLINE(seg_info_ptr[i].attr)) {
   164 +				DEBUG(10,("samfs_is_offline: file %s has offline segment %d\n",
   170 +				number_of_segments_offline++;
   165 +					path, i+1));
       
   166 +				break;
       
   167 +			}
   171 +			}
   168 +		}
   172 +		}
       
   173 +		DEBUG(10,("samfs_is_offline: file %s has %d offline segments\n"
       
   174 +			, path, number_of_segments_offline));
   169 +		TALLOC_FREE(seg_info_ptr);
   175 +		TALLOC_FREE(seg_info_ptr);
   170 +	}
   176 +	}
   171 +	return offline;
   177 +	return (number_of_segments_offline) ? true : false ;
   172 +}
   178 +}
   173 +
   179 +
   174 +/*
   180 +/*
   175 + * release a file-command to SAM-stagger
   181 + * release a file-command to SAM-stagger
   176 + */
   182 + */
   181 + *
   187 + *
   182 + * Release the local file in the sense of SAM-QFS.
   188 + * Release the local file in the sense of SAM-QFS.
   183 + * See sam_release(3) for details.
   189 + * See sam_release(3) for details.
   184 + *
   190 + *
   185 + */
   191 + */
   186 +static int samfs_set_offline(struct vfs_handle_struct *handle, const char *path)
   192 +static int samfs_set_offline(struct vfs_handle_struct *handle, const struct smb_filename *fname)
   187 +{
   193 +{
   188 +	int result;
   194 +	int result;
       
   195 +	NTSTATUS status;
       
   196 +	char *path;
       
   197 +
       
   198 +        status = get_full_smb_filename(talloc_tos(), fname, &path);
       
   199 +        if (!NT_STATUS_IS_OK(status)) {
       
   200 +                errno = map_errno_from_nt_status(status);
       
   201 +                return false;
       
   202 +        }
   189 +
   203 +
   190 +	result = sam_release(path, "i");
   204 +	result = sam_release(path, "i");
   191 +	if (result != 0) {
   205 +	if (result != 0) {
   192 +		DEBUG(10,("samfs_set_offline: sam_release %s returned %s\n",
   206 +		DEBUG(10,("samfs_set_offline: sam_release %s returned %s\n",
   193 +			path, strerror(errno)));
   207 +			path, strerror(errno)));