[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-261-g431e63c

Tim Prouty tprouty at samba.org
Mon Jul 6 22:42:12 GMT 2009


The branch, master has been updated
       via  431e63cd8bfff6f67b6e6595ee5a054877709c0d (commit)
       via  38b081f852db83cf3c2cce41b564449070be4be2 (commit)
       via  fd73ab5782bc086f67f159aac378c8dcb95ed4aa (commit)
       via  3cb0e521e1bdddde972b6fd08fb86f7fe73da8d5 (commit)
       via  f39232a8fb93cfccfe1533ab613867572ff7f848 (commit)
       via  18a27a8df223ba8eb0faf6a64384acce174f3ace (commit)
       via  99bd4fda0cd97eb211549a511a2ff6153c2bde2d (commit)
       via  0f6e10886f3f778fe301ee981873f29d295d39c5 (commit)
       via  de3246eae2b1234cc7fcb7d4dd6c6863ab9d31b3 (commit)
       via  258952aa85f2a68e2d2362522f6114c6a439f1e3 (commit)
       via  133e915a81510f543f6458f377857d4f1b680970 (commit)
       via  1b8ffb36b131268e602f494aecf34b0866ef7e34 (commit)
       via  e4a85da5708a08f06a50f4f6b95e22d0e148d85e (commit)
       via  5a09ba460cb757823e1deb8b2f2ae762765846c0 (commit)
      from  c41e5e1342a06456b4a5b101f46a394d6a4252bb (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 431e63cd8bfff6f67b6e6595ee5a054877709c0d
Author: Tim Prouty <tprouty at samba.org>
Date:   Mon Jul 6 15:26:57 2009 -0700

    s3: Update streaminfo implementations now that only base names are passed through the vfs

commit 38b081f852db83cf3c2cce41b564449070be4be2
Author: Tim Prouty <tprouty at samba.org>
Date:   Mon Jul 6 14:18:05 2009 -0700

    s3 smb2: Fix unused variable warning

commit fd73ab5782bc086f67f159aac378c8dcb95ed4aa
Author: Tim Prouty <tprouty at samba.org>
Date:   Fri Jul 3 17:15:30 2009 -0700

    s3 audit: Fix a memory leak

commit 3cb0e521e1bdddde972b6fd08fb86f7fe73da8d5
Author: Tim Prouty <tprouty at samba.org>
Date:   Thu Jul 2 13:39:20 2009 -0700

    s3: Plumb smb_filename through SMB_VFS_NTIMES

commit f39232a8fb93cfccfe1533ab613867572ff7f848
Author: Tim Prouty <tprouty at samba.org>
Date:   Thu Jul 2 13:13:14 2009 -0700

    s3 catia: Remove pointless VOPs from catia

commit 18a27a8df223ba8eb0faf6a64384acce174f3ace
Author: Tim Prouty <tprouty at samba.org>
Date:   Thu Jul 2 10:27:01 2009 -0700

    s3 sticky write time: Removed unused args and tighten up a function by making an arg const

commit 99bd4fda0cd97eb211549a511a2ff6153c2bde2d
Author: Tim Prouty <tprouty at samba.org>
Date:   Mon Jul 6 14:36:16 2009 -0700

    s3: Plumb smb_filename around SMB_VFS_CHFLAGS
    
    SMB_VFS_CHFLAGS isn't actually getting the smb_filename struct for now
    since it only operates on the basefile.  This is the strategy for all
    path-based operations that will never actually operate on a stream.
    
    By clarifying the meaning of path based operations that don't take an
    smb_filename struct, modules that implement streams such as vfs_onefs
    no longer need to implement SMB_VFS_CHFLAGS to ensure it's only called
    on the base_name.

commit 0f6e10886f3f778fe301ee981873f29d295d39c5
Author: Tim Prouty <tprouty at samba.org>
Date:   Wed Jul 1 16:15:52 2009 -0700

    s3: Change some filename_convert to pass in NULL for char **fname argument

commit de3246eae2b1234cc7fcb7d4dd6c6863ab9d31b3
Author: Tim Prouty <tprouty at samba.org>
Date:   Wed Jul 1 16:14:40 2009 -0700

    s3: Add ability to pass NULL to filename_convert for the char *fname
    
    The goal is to eventually remove the need for the char **fname argument
    once all callers have standardized on smb_filename.

commit 258952aa85f2a68e2d2362522f6114c6a439f1e3
Author: Tim Prouty <tprouty at samba.org>
Date:   Thu Jul 2 09:27:44 2009 -0700

    s3: Plumb smb_filename through SMB_VFS_UNLINK

commit 133e915a81510f543f6458f377857d4f1b680970
Author: Tim Prouty <tprouty at samba.org>
Date:   Tue Jun 30 23:08:02 2009 -0700

    s3 audit: Remove some recently introduced memory leaks in the audit modules

commit 1b8ffb36b131268e602f494aecf34b0866ef7e34
Author: Tim Prouty <tprouty at samba.org>
Date:   Tue Jun 30 22:44:39 2009 -0700

    s3 audit: Remove the usesless static function declarations from the audit modules

commit e4a85da5708a08f06a50f4f6b95e22d0e148d85e
Author: Tim Prouty <tprouty at samba.org>
Date:   Tue Jun 30 16:41:48 2009 -0700

    s3 onefs: Fix failure in POSIX smbtorture test
    
    The return value of readlink was a bool instead of an int,
    which caused the length of the returned value to never be
    >1.

commit 5a09ba460cb757823e1deb8b2f2ae762765846c0
Author: Tim Prouty <tprouty at samba.org>
Date:   Tue Jun 30 17:04:38 2009 -0700

    s3: Plumb smb_filename through SMB_VFS_RENAME

-----------------------------------------------------------------------

Summary of changes:
 examples/VFS/skel_opaque.c              |   17 +-
 examples/VFS/skel_transparent.c         |   17 +-
 source3/include/proto.h                 |   25 +-
 source3/include/vfs.h                   |   14 +-
 source3/locking/locking.c               |    3 +-
 source3/modules/onefs.h                 |    8 +-
 source3/modules/onefs_streams.c         |  177 ++++---
 source3/modules/vfs_acl_tdb.c           |   27 +-
 source3/modules/vfs_audit.c             |   97 ++--
 source3/modules/vfs_cap.c               |   97 +++-
 source3/modules/vfs_catia.c             |  159 +++----
 source3/modules/vfs_default.c           |   64 ++-
 source3/modules/vfs_extd_audit.c        |  102 ++--
 source3/modules/vfs_full_audit.c        |  857 +++++++++++--------------------
 source3/modules/vfs_netatalk.c          |   59 ++-
 source3/modules/vfs_onefs.c             |    7 +-
 source3/modules/vfs_onefs_shadow_copy.c |  100 +++-
 source3/modules/vfs_recycle.c           |  180 +++++--
 source3/modules/vfs_shadow_copy2.c      |   44 ++-
 source3/modules/vfs_streams_depot.c     |  182 +++----
 source3/modules/vfs_streams_xattr.c     |  153 +++---
 source3/modules/vfs_syncops.c           |   15 +-
 source3/modules/vfs_xattr_tdb.c         |   26 +-
 source3/rpc_server/srv_srvsvc_nt.c      |    6 +-
 source3/smbd/close.c                    |  137 ++++--
 source3/smbd/dosmode.c                  |  118 ++---
 source3/smbd/fileio.c                   |   20 +-
 source3/smbd/filename.c                 |   18 +-
 source3/smbd/msdfs.c                    |   28 +-
 source3/smbd/nttrans.c                  |   18 +-
 source3/smbd/open.c                     |   68 ++--
 source3/smbd/reply.c                    |  510 ++++++++++++-------
 source3/smbd/smb2_create.c              |    4 +-
 source3/smbd/smb2_setinfo.c             |    1 -
 source3/smbd/trans2.c                   |  363 ++++++++------
 source3/torture/cmd_vfs.c               |   47 ++-
 36 files changed, 2018 insertions(+), 1750 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index ee8a3d8..a0cb533 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -169,9 +169,11 @@ static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct
 	return vfswrap_recvfile(NULL, fromfd, tofsp, offset, n);
 }
 
-static int skel_rename(vfs_handle_struct *handle,  const char *oldname, const char *newname)
+static int skel_rename(vfs_handle_struct *handle,
+		       const smb_filename *smb_fname_src,
+		       const smb_filename *smb_fname_dst)
 {
-	return vfswrap_rename(NULL,  oldname, newname);
+	return vfswrap_rename(NULL, smb_fname_src, smb_fname_dst);
 }
 
 static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
@@ -194,9 +196,10 @@ static int skel_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
 	return vfswrap_lstat(NULL, smb_fname);
 }
 
-static int skel_unlink(vfs_handle_struct *handle,  const char *path)
+static int skel_unlink(vfs_handle_struct *handle,
+		       const struct smb_filename *smb_fname)
 {
-	return vfswrap_unlink(NULL,  path);
+	return vfswrap_unlink(NULL, smb_fname);
 }
 
 static int skel_chmod(vfs_handle_struct *handle,  const char *path, mode_t mode)
@@ -234,9 +237,11 @@ static char *skel_getwd(vfs_handle_struct *handle,  char *buf)
 	return vfswrap_getwd(NULL,  buf);
 }
 
-static int skel_ntimes(vfs_handle_struct *handle,  const char *path, struct smb_file_time *ft)
+static int skel_ntimes(vfs_handle_struct *handle,
+		       const struct smb_filename *smb_fname,
+		       struct smb_file_time *ft)
 {
-	return vfswrap_ntimes(NULL,  path, ft);
+	return vfswrap_ntimes(NULL, smb_fname, ft);
 }
 
 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset)
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index 10b10b8..cce1d13 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -162,9 +162,11 @@ static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct
 	return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
 }
 
-static int skel_rename(vfs_handle_struct *handle,  const char *oldname, const char *newname)
+static int skel_rename(vfs_handle_struct *handle,
+		       const smb_filename *smb_fname_src,
+		       const smb_filename *smb_fname_dst)
 {
-	return SMB_VFS_NEXT_RENAME(handle, oldname, newname);
+	return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
 }
 
 static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
@@ -187,9 +189,10 @@ static int skel_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
 	return SMB_VFS_NEXT_LSTAT(handle, smb_fname);
 }
 
-static int skel_unlink(vfs_handle_struct *handle,  const char *path)
+static int skel_unlink(vfs_handle_struct *handle,
+		       const struct smb_filename *smb_fname)
 {
-	return SMB_VFS_NEXT_UNLINK(handle, path);
+	return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
 }
 
 static int skel_chmod(vfs_handle_struct *handle,  const char *path, mode_t mode)
@@ -227,9 +230,11 @@ static char *skel_getwd(vfs_handle_struct *handle,  char *buf)
 	return SMB_VFS_NEXT_GETWD(handle, buf);
 }
 
-static int skel_ntimes(vfs_handle_struct *handle,  const char *path, struct smb_file_time *ft)
+static int skel_ntimes(vfs_handle_struct *handle,
+		       const struct smb_filename *smb_fname,
+		       struct smb_file_time *ft)
 {
-	return SMB_VFS_NEXT_NTIMES(handle, path, ft);
+	return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
 }
 
 static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index e4bcdb5..dfcb38d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3474,7 +3474,8 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, bool delete_on_close,
 void set_delete_on_close_token(struct share_mode_lock *lck, const UNIX_USER_TOKEN *tok);
 void set_delete_on_close_lck(struct share_mode_lock *lck, bool delete_on_close, const UNIX_USER_TOKEN *tok);
 bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const UNIX_USER_TOKEN *tok);
-bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
+bool set_sticky_write_time(const struct file_id fileid,
+			   struct timespec write_time);
 bool set_write_time(struct file_id fileid, struct timespec write_time);
 int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *,
 				 const char *, void *),
@@ -6238,14 +6239,12 @@ mode_t unix_mode(connection_struct *conn, int dosmode, const char *fname,
 uint32 dos_mode_msdfs(connection_struct *conn, const char *path, const SMB_STRUCT_STAT *sbuf);
 int dos_attributes_to_stat_dos_flags(uint32_t dosmode);
 uint32 dos_mode(connection_struct *conn, const char *path, const SMB_STRUCT_STAT *sbuf);
-int file_set_dosmode(connection_struct *conn, const char *fname,
-		     uint32 dosmode, SMB_STRUCT_STAT *st,
-		     const char *parent_dir,
-		     bool newfile);
-int file_ntimes(connection_struct *conn, const char *fname,
-		struct smb_file_time *ft, const SMB_STRUCT_STAT *psbuf);
-bool set_sticky_write_time_path(connection_struct *conn, const char *fname,
-			 struct file_id fileid, const struct timespec mtime);
+int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
+		     uint32 dosmode, const char *parent_dir, bool newfile);
+int file_ntimes(connection_struct *conn, const struct smb_filename *smb_fname,
+		struct smb_file_time *ft);
+bool set_sticky_write_time_path(struct file_id fileid,
+				const struct timespec mtime);
 bool set_sticky_write_time_fsp(struct files_struct *fsp, const struct timespec mtime);
 bool update_write_time(struct files_struct *fsp);
 
@@ -6872,12 +6871,11 @@ void reply_printwrite(struct smb_request *req);
 void reply_mkdir(struct smb_request *req);
 NTSTATUS rmdir_internals(TALLOC_CTX *ctx,
 			connection_struct *conn,
-			const char *directory);
+			struct smb_filename *smb_dname);
 void reply_rmdir(struct smb_request *req);
 NTSTATUS rename_internals_fsp(connection_struct *conn,
 			files_struct *fsp,
-			char *newname,
-			const char *newname_last_component,
+			const struct smb_filename *smb_fname_dst_in,
 			uint32 attrs,
 			bool replace_if_exists);
 NTSTATUS rename_internals(TALLOC_CTX *ctx,
@@ -7049,8 +7047,7 @@ NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
 		const struct smb_filename *smb_fname_new);
 NTSTATUS smb_set_file_time(connection_struct *conn,
 			   files_struct *fsp,
-			   const char *fname,
-			   const SMB_STRUCT_STAT *psbuf,
+			   const struct smb_filename *smb_fname,
 			   struct smb_file_time *ft,
 			   bool setting_write_time);
 void reply_findclose(struct smb_request *req);
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 2a0c5ec..91bda47 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -118,7 +118,8 @@
 /* Leave at 25 - not yet released. Add locking calls. -- zkirsch. */
 /* Leave at 25 - not yet released. Add strict locking calls. -- drichards. */
 /* Changed to version 26 - Plumb struct smb_filename to SMB_VFS_CREATE_FILE,
-			   SMB_VFS_OPEN, SMB_VFS_STAT, SMB_VFS_LSTAT. */
+			   SMB_VFS_OPEN, SMB_VFS_STAT, SMB_VFS_LSTAT,
+			   SMB_VFS_RENAME, SMB_VFS_UNLINK, SMB_VFS_NTIMES.  */
 
 #define SMB_VFS_INTERFACE_VERSION 26
 
@@ -357,13 +358,16 @@ struct vfs_ops {
 		SMB_OFF_T (*lseek)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_OFF_T offset, int whence);
 		ssize_t (*sendfile)(struct vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
 		ssize_t (*recvfile)(struct vfs_handle_struct *handle, int fromfd, files_struct *tofsp, SMB_OFF_T offset, size_t count);
-		int (*rename)(struct vfs_handle_struct *handle, const char *oldname, const char *newname);
+		int (*rename)(struct vfs_handle_struct *handle,
+			      const struct smb_filename *smb_fname_src,
+			      const struct smb_filename *smb_fname_dst);
 		int (*fsync)(struct vfs_handle_struct *handle, struct files_struct *fsp);
 		int (*stat)(struct vfs_handle_struct *handle, struct smb_filename *smb_fname);
 		int (*fstat)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_STAT *sbuf);
 		int (*lstat)(struct vfs_handle_struct *handle, struct smb_filename *smb_filename);
 		uint64_t (*get_alloc_size)(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
-		int (*unlink)(struct vfs_handle_struct *handle, const char *path);
+		int (*unlink)(struct vfs_handle_struct *handle,
+			      const struct smb_filename *smb_fname);
 		int (*chmod)(struct vfs_handle_struct *handle, const char *path, mode_t mode);
 		int (*fchmod)(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode);
 		int (*chown)(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid);
@@ -371,7 +375,9 @@ struct vfs_ops {
 		int (*lchown)(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid);
 		int (*chdir)(struct vfs_handle_struct *handle, const char *path);
 		char *(*getwd)(struct vfs_handle_struct *handle, char *buf);
-		int (*ntimes)(struct vfs_handle_struct *handle, const char *path, struct smb_file_time *ft);
+		int (*ntimes)(struct vfs_handle_struct *handle,
+			      const struct smb_filename *smb_fname,
+			      struct smb_file_time *ft);
 		int (*ftruncate)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_OFF_T offset);
 		bool (*lock)(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
 		int (*kernel_flock)(struct vfs_handle_struct *handle, struct files_struct *fsp, uint32 share_mode);
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index dd735be..78064cf 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -1415,7 +1415,8 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const UNIX_USE
 	return True;
 }
 
-bool set_sticky_write_time(struct file_id fileid, struct timespec write_time)
+bool set_sticky_write_time(const struct file_id fileid,
+			   struct timespec write_time)
 {
 	struct share_mode_lock *lck;
 
diff --git a/source3/modules/onefs.h b/source3/modules/onefs.h
index 6cb8036..88ba5a9 100644
--- a/source3/modules/onefs.h
+++ b/source3/modules/onefs.h
@@ -61,8 +61,9 @@ NTSTATUS onefs_create_file(vfs_handle_struct *handle,
 
 int onefs_close(vfs_handle_struct *handle, struct files_struct *fsp);
 
-int onefs_rename(vfs_handle_struct *handle, const char *oldname,
-		 const char *newname);
+int onefs_rename(vfs_handle_struct *handle,
+		 const struct smb_filename *smb_fname_src,
+		 const struct smb_filename *smb_fname_dst);
 
 int onefs_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname);
 
@@ -73,9 +74,6 @@ int onefs_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname);
 
 int onefs_unlink(vfs_handle_struct *handle, const char *path);
 
-int onefs_chflags(vfs_handle_struct *handle, const char *path,
-		  unsigned int flags);
-
 NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
 			  struct files_struct *fsp,
 			  const char *fname,
diff --git a/source3/modules/onefs_streams.c b/source3/modules/onefs_streams.c
index a4c6146..91917ee 100644
--- a/source3/modules/onefs_streams.c
+++ b/source3/modules/onefs_streams.c
@@ -195,68 +195,80 @@ static int get_stream_dir_fd(connection_struct *conn, const char *base,
 	return dir_fd;
 }
 
-int onefs_rename(vfs_handle_struct *handle, const char *oldname,
-		 const char *newname)
+int onefs_rename(vfs_handle_struct *handle,
+		 const struct smb_filename *smb_fname_src,
+		 const struct smb_filename *smb_fname_dst)
 {
-	TALLOC_CTX *frame = NULL;
-	int ret = -1;
-	int dir_fd = -1;
+	struct smb_filename *smb_fname_src_onefs = NULL;
+	struct smb_filename *smb_fname_dst_onefs = NULL;
+	NTSTATUS status;
 	int saved_errno;
-	bool old_is_stream;
-	bool new_is_stream;
-	char *obase = NULL;
-	char *osname = NULL;
-	char *nbase = NULL;
-	char *nsname = NULL;
+	int dir_fd = -1;
+	int ret = -1;
 
 	START_PROFILE(syscall_rename_at);
 
-	frame = talloc_stackframe();
-
-	ret = onefs_is_stream(oldname, &obase, &osname, &old_is_stream);
-	if (ret) {
-		END_PROFILE(syscall_rename_at);
-		return ret;
+	if (!is_ntfs_stream_smb_fname(smb_fname_src) &&
+	    !is_ntfs_stream_smb_fname(smb_fname_dst)) {
+		ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src,
+					  smb_fname_dst);
+		goto done;
 	}
 
-	ret = onefs_is_stream(newname, &nbase, &nsname, &new_is_stream);
-	if (ret) {
-		END_PROFILE(syscall_rename_at);
-		return ret;
+	/* For now don't allow renames from or to the default stream. */
+	if (is_ntfs_default_stream_smb_fname(smb_fname_src) ||
+	    is_ntfs_default_stream_smb_fname(smb_fname_dst)) {
+		errno = ENOSYS;
+		goto done;
 	}
 
-	if (!old_is_stream && !new_is_stream) {
-		ret = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
-		END_PROFILE(syscall_rename_at);
-		return ret;
+	/* prep stream smb_filename structs. */
+	status = onefs_stream_prep_smb_fname(talloc_tos(), smb_fname_src,
+					     &smb_fname_src_onefs);
+	if (!NT_STATUS_IS_OK(status)) {
+		errno = map_errno_from_nt_status(status);
+		goto done;
+	}
+	status = onefs_stream_prep_smb_fname(talloc_tos(), smb_fname_dst,
+					     &smb_fname_dst_onefs);
+	if (!NT_STATUS_IS_OK(status)) {
+		errno = map_errno_from_nt_status(status);
+		goto done;
 	}
 
-	dir_fd = get_stream_dir_fd(handle->conn, obase, NULL);
+	dir_fd = get_stream_dir_fd(handle->conn, smb_fname_src->base_name,
+				   NULL);
 	if (dir_fd < -1) {
 		goto done;
 	}
 
-	DEBUG(8,("onefs_rename called for %s : %s  => %s : %s\n",
-		obase, osname,  nbase, nsname));
+	DEBUG(8, ("onefs_rename called for %s => %s\n",
+		  smb_fname_str_dbg(smb_fname_src_onefs),
+		  smb_fname_str_dbg(smb_fname_dst_onefs)));
 
 	/* Handle rename of stream to default stream specially. */
-	if (nsname == NULL) {
-		ret = enc_renameat(dir_fd, osname, ENC_DEFAULT, AT_FDCWD,
-				   nbase, ENC_DEFAULT);
+	if (smb_fname_dst_onefs->stream_name == NULL) {
+		ret = enc_renameat(dir_fd, smb_fname_src_onefs->stream_name,
+				   ENC_DEFAULT, AT_FDCWD,
+				   smb_fname_dst_onefs->base_name,
+				   ENC_DEFAULT);
 	} else {
-		ret = enc_renameat(dir_fd, osname, ENC_DEFAULT, dir_fd, nsname,
+		ret = enc_renameat(dir_fd, smb_fname_src_onefs->stream_name,
+				   ENC_DEFAULT, dir_fd,
+				   smb_fname_dst_onefs->stream_name,
 				   ENC_DEFAULT);
 	}
 
  done:
 	END_PROFILE(syscall_rename_at);
+	TALLOC_FREE(smb_fname_src_onefs);
+	TALLOC_FREE(smb_fname_dst_onefs);
 
 	saved_errno = errno;
 	if (dir_fd >= 0) {
 		close(dir_fd);
 	}
 	errno = saved_errno;
-	TALLOC_FREE(frame);
 	return ret;
 }
 
@@ -450,50 +462,61 @@ int onefs_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
 	return ret;
 }
 
-int onefs_unlink(vfs_handle_struct *handle, const char *path)
+int onefs_unlink(vfs_handle_struct *handle,
+		  const struct smb_filename *smb_fname)
 {
+	struct smb_filename *smb_fname_onefs = NULL;
 	int ret;
 	bool is_stream;
 	char *base = NULL;
 	char *stream = NULL;
 	int dir_fd, saved_errno;
 
-	ret = onefs_is_stream(path, &base, &stream, &is_stream);
-	if (ret) {
-		return ret;
+	/* Not a stream. */
+	if (!is_ntfs_stream_smb_fname(smb_fname)) {
+		return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
 	}
 
-	if (!is_stream)	{
-		return SMB_VFS_NEXT_UNLINK(handle, path);
+	status = onefs_stream_prep_smb_fname(talloc_tos(), smb_fname,
+					     &smb_fname_onefs);
+	if (!NT_STATUS_IS_OK(status)) {
+		errno = map_errno_from_nt_status(status);
+		return -1;
 	}
 
-	/* If it's the ::$DATA stream just unlink the base file name. */
-	if (!stream) {
-		return SMB_VFS_NEXT_UNLINK(handle, base);
+	/* Default stream (the ::$DATA was just stripped off). */
+	if (!is_ntfs_stream_smb_fname(smb_fname_onefs)) {
+		ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_onefs);
+		goto out;
 	}
 
-	dir_fd = get_stream_dir_fd(handle->conn, base, NULL);
+	dir_fd = get_stream_dir_fd(handle->conn, smb_fname_onefs->base_name,
+				   NULL);
 	if (dir_fd < 0) {
-		return -1;
+		ret = -1;
+		goto out;
 	}
 
-	ret = enc_unlinkat(dir_fd, stream, ENC_DEFAULT, 0);
+	ret = enc_unlinkat(dir_fd, smb_fname_onefs->stream_name, ENC_DEFAULT,
+			   0);
 
 	saved_errno = errno;
 	close(dir_fd);
 	errno = saved_errno;
+ out:
+	TALLOC_FREE(smb_fname_onefs);
 	return ret;
 }
 
-int onefs_vtimes_streams(vfs_handle_struct *handle, const char *fname,
+int onefs_vtimes_streams(vfs_handle_struct *handle,
+			 const struct smb_filename *smb_fname,
 			 int flags, struct timespec times[3])
 {
+	struct smb_filename *smb_fname_onefs = NULL;
 	int ret;
-	bool is_stream;
-	char *base;
-	char *stream;
 	int dirfd;
 	int saved_errno;
+	NTSTATUS status;
 
 	START_PROFILE(syscall_ntimes);
 
@@ -501,44 +524,41 @@ int onefs_vtimes_streams(vfs_handle_struct *handle, const char *fname,
 	if (ret)
 		return ret;
 
-	if (!is_stream) {
-		ret = vtimes(fname, times, flags);
+	if (!is_ntfs_stream_smb_fname(smb_fname)) {
+		ret = vtimes(smb_fname->base_name, times, flags);
 		return ret;
 	}
 
-	dirfd = get_stream_dir_fd(handle->conn, base, NULL);
-	if (dirfd < -1) {
+	status = onefs_stream_prep_smb_fname(talloc_tos(), smb_fname,
+					     &smb_fname_onefs);
+	if (!NT_STATUS_IS_OK(status)) {
+		errno = map_errno_from_nt_status(status);
 		return -1;
 	}
 
-	ret = enc_vtimesat(dirfd, stream, ENC_DEFAULT, times, flags);
+	/* Default stream (the ::$DATA was just stripped off). */
+	if (!is_ntfs_stream_smb_fname(smb_fname_onefs)) {
+		ret = vtimes(smb_fname_onefs->base_name, times, flags);
+		goto out;
+	}
+
+	dirfd = get_stream_dir_fd(handle->conn, smb_fname->base_name, NULL);
+	if (dirfd < -1) {
+		ret = -1;
+		goto out;
+	}
 
-	END_PROFILE(syscall_ntimes);
+	ret = enc_vtimesat(dirfd, smb_fname_onefs->stream_name, ENC_DEFAULT,
+			   times, flags);
 
 	saved_errno = errno;
 	close(dirfd);
 	errno = saved_errno;
-	return ret;
-}
-
-int onefs_chflags(vfs_handle_struct *handle, const char *path,
-		  unsigned int flags)
-{
-	char *base = NULL;
-	char *stream = NULL;
-
-	if (!NT_STATUS_IS_OK(onefs_split_ntfs_stream_name(talloc_tos(), path,
-							  &base, &stream))) {
-		DEBUG(10, ("onefs_split_ntfs_stream_name failed\n"));
-		errno = ENOMEM;
-		return -1;
-	}
 
-	/*
-	 * Only set the attributes on the base file.  ifs_createfile handles
-	 * file creation attribute semantics.
-	 */
-	return SMB_VFS_NEXT_CHFLAGS(handle, base, flags);
+ out:
+	END_PROFILE(syscall_ntimes);
+	TALLOC_FREE(smb_fname_onefs);
+	return ret;
 }
 
 /*
@@ -719,17 +739,10 @@ NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list