1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

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 <pchand@vmware.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Jeremy Allison 2019-10-18 09:24:38 -07:00 committed by Ralph Boehme
parent f30b8b3aa1
commit d44a84295b
2 changed files with 27 additions and 26 deletions

View File

@ -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,

View File

@ -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);