From e129384d7c1df664e447186673dd107e190e2894 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Mon, 22 Jun 2009 15:26:56 -0700 Subject: s3: Plumb smb_filename through SMB_VFS_STAT and SMB_VFS_LSTAT This patch introduces two new temporary helper functions vfs_stat_smb_fname and vfs_lstat_smb_fname. They basically allowed me to call the new smb_filename version of stat, while avoiding plumbing it through callers that are still too inconvenient. As the conversion moves along, I will be able to remove callers of this, with the goal being to remove all callers. There was also a bug in create_synthetic_smb_fname_split (also a temporary utility function) that caused it to incorrectly handle filenames with ':'s in them when in posix mode. This is now fixed. --- source3/torture/cmd_vfs.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'source3/torture') diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index f1f4aed77c..0a682c7fd9 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -554,19 +554,30 @@ static NTSTATUS cmd_stat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c const char *group; struct passwd *pwd = NULL; struct group *grp = NULL; + struct smb_filename *smb_fname = NULL; SMB_STRUCT_STAT st; time_t tmp_time; + NTSTATUS status; if (argc != 2) { printf("Usage: stat \n"); return NT_STATUS_OK; } - ret = SMB_VFS_STAT(vfs->conn, argv[1], &st); + status = create_synthetic_smb_fname_split(mem_ctx, argv[1], NULL, + &smb_fname); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + ret = SMB_VFS_STAT(vfs->conn, smb_fname); if (ret == -1) { printf("stat: error=%d (%s)\n", errno, strerror(errno)); + TALLOC_FREE(smb_fname); return NT_STATUS_UNSUCCESSFUL; } + st = smb_fname->st; + TALLOC_FREE(smb_fname); pwd = sys_getpwuid(st.st_ex_uid); if (pwd != NULL) user = pwd->pw_name; @@ -684,18 +695,29 @@ static NTSTATUS cmd_lstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char *group; struct passwd *pwd = NULL; struct group *grp = NULL; + struct smb_filename *smb_fname = NULL; SMB_STRUCT_STAT st; time_t tmp_time; + NTSTATUS status; if (argc != 2) { printf("Usage: lstat \n"); return NT_STATUS_OK; } - if (SMB_VFS_LSTAT(vfs->conn, argv[1], &st) == -1) { + status = create_synthetic_smb_fname_split(mem_ctx, argv[1], NULL, + &smb_fname); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (SMB_VFS_LSTAT(vfs->conn, smb_fname) == -1) { printf("lstat: error=%d (%s)\n", errno, strerror(errno)); + TALLOC_FREE(smb_fname); return NT_STATUS_UNSUCCESSFUL; } + st = smb_fname->st; + TALLOC_FREE(smb_fname); pwd = sys_getpwuid(st.st_ex_uid); if (pwd != NULL) user = pwd->pw_name; -- cgit