From 49ca690b4b22ee6e597179059c9442e94c5bd423 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 14 May 2009 15:34:42 +0200 Subject: Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STAT This patch introduces struct stat_ex { dev_t st_ex_dev; ino_t st_ex_ino; mode_t st_ex_mode; nlink_t st_ex_nlink; uid_t st_ex_uid; gid_t st_ex_gid; dev_t st_ex_rdev; off_t st_ex_size; struct timespec st_ex_atime; struct timespec st_ex_mtime; struct timespec st_ex_ctime; struct timespec st_ex_btime; /* birthtime */ blksize_t st_ex_blksize; blkcnt_t st_ex_blocks; }; typedef struct stat_ex SMB_STRUCT_STAT; It is really large because due to the friendly libc headers playing macro tricks with fields like st_ino, so I renamed them to st_ex_xxx. Why this change? To support birthtime, we already have quite a few #ifdef's at places where it does not really belong. With a stat struct that we control, we can consolidate the nanosecond timestamps and the birthtime deep in the VFS stat calls. At this moment it is triggered by a request to support the birthtime field for GPFS. GPFS does not extend the system level struct stat, but instead has a separate call that gets us the additional information beyond posix. Without being able to do that within the VFS stat calls, that support would have to be scattered around the main smbd code. It will very likely break all the onefs modules, but I think the changes will be reasonably easy to do. --- source3/client/client.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'source3/client/client.c') diff --git a/source3/client/client.c b/source3/client/client.c index 59e5c1ad72..13dee6081d 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -3022,7 +3022,7 @@ static int cmd_getfacl(void) } d_printf("# file: %s\n", src); - d_printf("# owner: %u\n# group: %u\n", (unsigned int)sbuf.st_uid, (unsigned int)sbuf.st_gid); + d_printf("# owner: %u\n# group: %u\n", (unsigned int)sbuf.st_ex_uid, (unsigned int)sbuf.st_ex_gid); if (num_file_acls == 0 && num_dir_acls == 0) { d_printf("No acls found.\n"); @@ -3120,6 +3120,7 @@ static int cmd_stat(void) fstring mode_str; SMB_STRUCT_STAT sbuf; struct tm *lt; + time_t tmp_time; if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) { d_printf("stat file\n"); @@ -3152,30 +3153,31 @@ static int cmd_stat(void) /* Print out the stat values. */ d_printf("File: %s\n", src); d_printf("Size: %-12.0f\tBlocks: %u\t%s\n", - (double)sbuf.st_size, - (unsigned int)sbuf.st_blocks, - filetype_to_str(sbuf.st_mode)); + (double)sbuf.st_ex_size, + (unsigned int)sbuf.st_ex_blocks, + filetype_to_str(sbuf.st_ex_mode)); #if defined(S_ISCHR) && defined(S_ISBLK) - if (S_ISCHR(sbuf.st_mode) || S_ISBLK(sbuf.st_mode)) { + if (S_ISCHR(sbuf.st_ex_mode) || S_ISBLK(sbuf.st_ex_mode)) { d_printf("Inode: %.0f\tLinks: %u\tDevice type: %u,%u\n", - (double)sbuf.st_ino, - (unsigned int)sbuf.st_nlink, - unix_dev_major(sbuf.st_rdev), - unix_dev_minor(sbuf.st_rdev)); + (double)sbuf.st_ex_ino, + (unsigned int)sbuf.st_ex_nlink, + unix_dev_major(sbuf.st_ex_rdev), + unix_dev_minor(sbuf.st_ex_rdev)); } else #endif d_printf("Inode: %.0f\tLinks: %u\n", - (double)sbuf.st_ino, - (unsigned int)sbuf.st_nlink); + (double)sbuf.st_ex_ino, + (unsigned int)sbuf.st_ex_nlink); d_printf("Access: (0%03o/%s)\tUid: %u\tGid: %u\n", - ((int)sbuf.st_mode & 0777), - unix_mode_to_str(mode_str, sbuf.st_mode), - (unsigned int)sbuf.st_uid, - (unsigned int)sbuf.st_gid); + ((int)sbuf.st_ex_mode & 0777), + unix_mode_to_str(mode_str, sbuf.st_ex_mode), + (unsigned int)sbuf.st_ex_uid, + (unsigned int)sbuf.st_ex_gid); - lt = localtime(&sbuf.st_atime); + tmp_time = convert_timespec_to_time_t(sbuf.st_ex_atime); + lt = localtime(&tmp_time); if (lt) { strftime(mode_str, sizeof(mode_str), "%Y-%m-%d %T %z", lt); } else { @@ -3183,7 +3185,8 @@ static int cmd_stat(void) } d_printf("Access: %s\n", mode_str); - lt = localtime(&sbuf.st_mtime); + tmp_time = convert_timespec_to_time_t(sbuf.st_ex_mtime); + lt = localtime(&tmp_time); if (lt) { strftime(mode_str, sizeof(mode_str), "%Y-%m-%d %T %z", lt); } else { @@ -3191,7 +3194,8 @@ static int cmd_stat(void) } d_printf("Modify: %s\n", mode_str); - lt = localtime(&sbuf.st_ctime); + tmp_time = convert_timespec_to_time_t(sbuf.st_ex_ctime); + lt = localtime(&tmp_time); if (lt) { strftime(mode_str, sizeof(mode_str), "%Y-%m-%d %T %z", lt); } else { @@ -3400,7 +3404,7 @@ static int cmd_newer(void) ok = next_token_talloc(ctx, &cmd_ptr,&buf,NULL); if (ok && (sys_stat(buf,&sbuf) == 0)) { - newer_than = sbuf.st_mtime; + newer_than = convert_timespec_to_time_t(sbuf.st_ex_mtime); DEBUG(1,("Getting files newer than %s", time_to_asc(newer_than))); } else { -- cgit From f55c7614bd7360b484f15c2290ab88195bb78094 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 May 2009 17:28:23 -0700 Subject: Add aync POSIX hardlink and symlink and torture test for them. Missing call cli_readlink() is next. Jeremy. --- source3/client/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/client/client.c') diff --git a/source3/client/client.c b/source3/client/client.c index 13dee6081d..d7c554efc0 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2725,7 +2725,7 @@ static int cmd_link(void) return 1; } - if (!cli_unix_hardlink(targetcli, targetname, newname)) { + if (!NT_STATUS_IS_OK(cli_posix_hardlink(targetcli, targetname, newname))) { d_printf("%s linking files (%s -> %s)\n", cli_errstr(targetcli), newname, oldname); return 1; } @@ -2776,7 +2776,7 @@ static int cmd_symlink(void) return 1; } - if (!cli_unix_symlink(targetcli, targetname, newname)) { + if (!NT_STATUS_IS_OK(cli_posix_symlink(targetcli, targetname, newname))) { d_printf("%s symlinking files (%s -> %s)\n", cli_errstr(targetcli), newname, targetname); return 1; -- cgit From bd1194810787901c5caa08961f97fecbcbd01978 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 May 2009 22:02:20 -0700 Subject: Add a smbclient "readlink" command and add docs for it. Jeremy. --- source3/client/client.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source3/client/client.c') diff --git a/source3/client/client.c b/source3/client/client.c index d7c554efc0..2edeb1ae2b 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2732,6 +2732,54 @@ static int cmd_link(void) return 0; } +/**************************************************************************** + UNIX readlink. +****************************************************************************/ + +static int cmd_readlink(void) +{ + TALLOC_CTX *ctx = talloc_tos(); + char *name= NULL; + char *buf = NULL; + char *targetname = NULL; + char linkname[PATH_MAX+1]; + struct cli_state *targetcli; + + if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { + d_printf("readlink \n"); + return 1; + } + name = talloc_asprintf(ctx, + "%s%s", + client_get_cur_dir(), + buf); + if (!name) { + return 1; + } + + if (!cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, &targetname)) { + d_printf("readlink %s: %s\n", name, cli_errstr(cli)); + return 1; + } + + if (!SERVER_HAS_UNIX_CIFS(targetcli)) { + d_printf("Server doesn't support UNIX CIFS calls.\n"); + return 1; + } + + if (!NT_STATUS_IS_OK(cli_posix_readlink(targetcli, name, + linkname, PATH_MAX+1))) { + d_printf("%s readlink on file %s\n", + cli_errstr(targetcli), name); + return 1; + } + + d_printf("%s -> %s\n", name, linkname); + + return 0; +} + + /**************************************************************************** UNIX symlink. ****************************************************************************/ @@ -3953,6 +4001,7 @@ static struct { {"q",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}}, {"queue",cmd_queue,"show the print queue",{COMPL_NONE,COMPL_NONE}}, {"quit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}}, + {"readlink",cmd_readlink,"filename Do a UNIX extensions readlink call on a symlink",{COMPL_REMOTE,COMPL_REMOTE}}, {"rd",cmd_rmdir," remove a directory",{COMPL_NONE,COMPL_NONE}}, {"recurse",cmd_recurse,"toggle directory recursion for mget and mput",{COMPL_NONE,COMPL_NONE}}, {"reget",cmd_reget," [local name] get a file restarting at end of local file",{COMPL_REMOTE,COMPL_LOCAL}}, -- cgit