From d44a84295b46cc6c540a9730a615a59c1f22a277 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 18 Oct 2019 09:24:38 -0700 Subject: [PATCH] s3: libsmb: Change generate_inode()/setup_stat() to modern coding standards. Change setup_stat() to be void. It doesn't return anything. Export so it can be used by upcoming smbc_readdirplus2() call. Remove unused SMBCCTX *context parameters. Remove unused talloc_stackframe(). Signed-off-by: Puran Chand Signed-off-by: Jeremy Allison Reviewed-by: Andreas Schneider --- source3/include/libsmb_internal.h | 5 ++++ source3/libsmb/libsmb_stat.c | 48 ++++++++++++++----------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index f3e44e875d8..16a5673e4d2 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -522,6 +522,11 @@ SMBC_attr_server(TALLOC_CTX *ctx, /* Functions in libsmb_stat.c */ +void setup_stat(struct stat *st, + const char *fname, + off_t size, + int mode); + int SMBC_stat_ctx(SMBCCTX *context, const char *fname, diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index 2f6e66c08e5..fb9dd63e7a6 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -32,16 +32,11 @@ * Generate an inode number from file name for those things that need it */ -static ino_t -generate_inode(SMBCCTX *context, - const char *name) +static ino_t generate_inode(const char *name) { - if (!context || !context->internal->initialized) { - errno = EINVAL; - return -1; + if (name == NULL) { + return (ino_t)-1; } - - if (!*name) return 2; /* FIXME, why 2 ??? */ return (ino_t)str_checksum(name); } @@ -50,15 +45,11 @@ generate_inode(SMBCCTX *context, * fstat below. */ -static int -setup_stat(SMBCCTX *context, - struct stat *st, - const char *fname, - off_t size, - int mode) +void setup_stat(struct stat *st, + const char *fname, + off_t size, + int mode) { - TALLOC_CTX *frame = talloc_stackframe(); - st->st_mode = 0; if (IS_DOS_DIR(mode)) { @@ -67,10 +58,18 @@ setup_stat(SMBCCTX *context, st->st_mode = SMBC_FILE_MODE; } - if (IS_DOS_ARCHIVE(mode)) st->st_mode |= S_IXUSR; - if (IS_DOS_SYSTEM(mode)) st->st_mode |= S_IXGRP; - if (IS_DOS_HIDDEN(mode)) st->st_mode |= S_IXOTH; - if (!IS_DOS_READONLY(mode)) st->st_mode |= S_IWUSR; + if (IS_DOS_ARCHIVE(mode)) { + st->st_mode |= S_IXUSR; + } + if (IS_DOS_SYSTEM(mode)) { + st->st_mode |= S_IXGRP; + } + if (IS_DOS_HIDDEN(mode)) { + st->st_mode |= S_IXOTH; + } + if (!IS_DOS_READONLY(mode)) { + st->st_mode |= S_IWUSR; + } st->st_size = size; #ifdef HAVE_STAT_ST_BLKSIZE @@ -92,11 +91,8 @@ setup_stat(SMBCCTX *context, } if (st->st_ino == 0) { - st->st_ino = generate_inode(context, fname); + st->st_ino = generate_inode(fname); } - - TALLOC_FREE(frame); - return True; /* FIXME: Is this needed ? */ } /* @@ -183,7 +179,7 @@ SMBC_stat_ctx(SMBCCTX *context, st->st_ino = ino; - setup_stat(context, st, fname, size, mode); + setup_stat(st, fname, size, mode); st->st_atime = convert_timespec_to_time_t(access_time_ts); st->st_ctime = convert_timespec_to_time_t(change_time_ts); @@ -288,7 +284,7 @@ SMBC_fstat_ctx(SMBCCTX *context, st->st_ino = ino; - setup_stat(context, st, file->fname, size, mode); + setup_stat(st, file->fname, size, mode); st->st_atime = convert_timespec_to_time_t(access_time_ts); st->st_ctime = convert_timespec_to_time_t(change_time_ts);