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/include/includes.h | 33 ++++++++++++++++++++++++++------- source3/include/proto.h | 11 ++--------- source3/include/smb_macros.h | 6 +++--- 3 files changed, 31 insertions(+), 19 deletions(-) (limited to 'source3/include') diff --git a/source3/include/includes.h b/source3/include/includes.h index 596c772d9e..a2f6048c27 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -435,13 +435,32 @@ typedef uint64_t br_off; * Type for stat structure. */ -#ifndef SMB_STRUCT_STAT -# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STAT64) && defined(HAVE_OFF64_T) -# define SMB_STRUCT_STAT struct stat64 -# else -# define SMB_STRUCT_STAT struct stat -# endif -#endif +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; + + /* + * Add space for VFS internal extensions. The initial user of this + * would be the onefs modules, passing the snapid from the stat calls + * to the file_id_create call. Maybe we'll have to expand this later, + * but the core of Samba should never look at this field. + */ + uint64_t vfs_private; +}; + +typedef struct stat_ex SMB_STRUCT_STAT; /* * Type for dirent structure. diff --git a/source3/include/proto.h b/source3/include/proto.h index e0b0e59700..c78d2c8e0b 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1010,13 +1010,6 @@ void srv_put_dos_date2(char *buf,int offset, time_t unixdate); void srv_put_dos_date3(char *buf,int offset,time_t unixdate); void put_long_date_timespec(char *p, struct timespec ts); void put_long_date(char *p, time_t t); -struct timespec get_create_timespec(const SMB_STRUCT_STAT *st,bool fake_dirs); -struct timespec get_atimespec(const SMB_STRUCT_STAT *pst); -void set_atimespec(SMB_STRUCT_STAT *pst, struct timespec ts); -struct timespec get_mtimespec(const SMB_STRUCT_STAT *pst); -void set_mtimespec(SMB_STRUCT_STAT *pst, struct timespec ts); -struct timespec get_ctimespec(const SMB_STRUCT_STAT *pst); -void set_ctimespec(SMB_STRUCT_STAT *pst, struct timespec ts); void dos_filetime_timespec(struct timespec *tsp); time_t make_unix_date2(const void *date_ptr, int zone_offset); time_t make_unix_date3(const void *date_ptr, int zone_offset); @@ -4087,7 +4080,7 @@ bool lp_recursive_veto_delete(int ); bool lp_dos_filemode(int ); bool lp_dos_filetimes(int ); bool lp_dos_filetime_resolution(int ); -bool lp_fake_dir_create_times(int ); +bool lp_fake_dir_create_times(void); bool lp_blocking_locks(int ); bool lp_inherit_perms(int ); bool lp_inherit_acls(int ); @@ -6174,7 +6167,7 @@ bool get_dir_entry(TALLOC_CTX *ctx, char **pp_fname_out, SMB_OFF_T *size, uint32 *mode, - time_t *date, + struct timespec *date, bool check_descend, bool ask_sharemode); bool is_visible_file(connection_struct *conn, const char *dir_path, const char *name, SMB_STRUCT_STAT *pst, bool use_veto); diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 22cfaaf581..7528883c2d 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -88,9 +88,9 @@ * stat structure is valid. */ -#define VALID_STAT(st) ((st).st_nlink != 0) -#define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR((st).st_mode)) -#define SET_STAT_INVALID(st) ((st).st_nlink = 0) +#define VALID_STAT(st) ((st).st_ex_nlink != 0) +#define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR((st).st_ex_mode)) +#define SET_STAT_INVALID(st) ((st).st_ex_nlink = 0) /* Macros to get at offsets within smb_lkrng and smb_unlkrng structures. We cannot define these as actual structures -- cgit From 93e16a08d46587a6eacaa05cd462ea316e9da8e4 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Tue, 26 May 2009 22:37:17 +0200 Subject: s3: fix build on systems with struct stat member st_flags --- source3/include/includes.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/include') diff --git a/source3/include/includes.h b/source3/include/includes.h index a2f6048c27..ba3866a03a 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -450,6 +450,9 @@ struct stat_ex { struct timespec st_ex_btime; /* birthtime */ blksize_t st_ex_blksize; blkcnt_t st_ex_blocks; +#ifdef HAVE_STAT_ST_FLAGS + uint32_t st_ex_flags; +#endif /* * Add space for VFS internal extensions. The initial user of this -- cgit From 4db54fff13c2dfd1ea307faa32cf1dd34916c924 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Tue, 26 May 2009 23:19:00 +0200 Subject: Revert "s3: fix build on systems with struct stat member st_flags" for a cleaner and more complete patch that Volker has in the queue :-) --- source3/include/includes.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/include') diff --git a/source3/include/includes.h b/source3/include/includes.h index ba3866a03a..a2f6048c27 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -450,9 +450,6 @@ struct stat_ex { struct timespec st_ex_btime; /* birthtime */ blksize_t st_ex_blksize; blkcnt_t st_ex_blocks; -#ifdef HAVE_STAT_ST_FLAGS - uint32_t st_ex_flags; -#endif /* * Add space for VFS internal extensions. The initial user of this -- cgit From dd0506d15ddb01b8f6e7b6be604a3445b73db434 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 26 May 2009 22:39:50 +0200 Subject: Attempt to fix the build on NetBSD --- source3/include/includes.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/include') diff --git a/source3/include/includes.h b/source3/include/includes.h index a2f6048c27..0d66c1cd6b 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -451,6 +451,9 @@ struct stat_ex { blksize_t st_ex_blksize; blkcnt_t st_ex_blocks; + uint32_t st_ex_flags; + uint32_t st_ex_mask; + /* * Add space for VFS internal extensions. The initial user of this * would be the onefs modules, passing the snapid from the stat calls -- cgit From 3ada1a19ab1309b0435ee84844b433b06ead0196 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 26 May 2009 23:37:14 +0200 Subject: Attempt to fix the build on HP/UX --- source3/include/includes.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/include') diff --git a/source3/include/includes.h b/source3/include/includes.h index 0d66c1cd6b..7bb72be692 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -431,6 +431,16 @@ typedef uint64_t br_off; #define IVAL_TO_SMB_OFF_T(buf,off) ((SMB_OFF_T)(( ((uint32)(IVAL((buf),(off)))) & 0xFFFFFFFF ))) #endif +#ifndef HAVE_BLKSIZE_T +/* This is mainly for HP/UX which defines st_blksize as long */ +typedef blksize_t long; +#endif + +#ifndef HAVE_BLKCNT_T +/* This is mainly for HP/UX which doesn't have blkcnt_t */ +typedef blkcnt_t long; +#endif + /* * Type for stat structure. */ -- cgit From ab5b1431a028482e4ab65a584db6aa35979680b2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 27 May 2009 08:09:23 +0200 Subject: Gna, how long do I program in C now??? :-) --- source3/include/includes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/include') diff --git a/source3/include/includes.h b/source3/include/includes.h index 7bb72be692..e468bd5c38 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -433,12 +433,12 @@ typedef uint64_t br_off; #ifndef HAVE_BLKSIZE_T /* This is mainly for HP/UX which defines st_blksize as long */ -typedef blksize_t long; +typedef long blksize_t; #endif #ifndef HAVE_BLKCNT_T /* This is mainly for HP/UX which doesn't have blkcnt_t */ -typedef blkcnt_t long; +typedef long blkcnt_t; #endif /* -- cgit From a4887e250b84c321c75d54b9d3adf6fcf7c27fed Mon Sep 17 00:00:00 2001 From: Marc VanHeyningen Date: Tue, 5 May 2009 21:18:50 +0000 Subject: s3: Allow child processes to exit gracefully if we are out of fds When we run out of file descriptors for some reason, every new connection forks a child that immediately panics causing smbd to coredump. This seems unnecessarily harsh; with this code change we now catch that error and merely log a message about it and exit without the core dump. Signed-off-by: Tim Prouty --- source3/include/proto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include') diff --git a/source3/include/proto.h b/source3/include/proto.h index c78d2c8e0b..717a972505 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1106,7 +1106,7 @@ char *clean_name(TALLOC_CTX *ctx, const char *s); ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos); int set_blocking(int fd, bool set); void smb_msleep(unsigned int t); -bool reinit_after_fork(struct messaging_context *msg_ctx, +NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx, struct event_context *ev_ctx, bool parent_longlived); bool yesno(const char *p); -- 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/include/proto.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source3/include') diff --git a/source3/include/proto.h b/source3/include/proto.h index 717a972505..a918c29aaa 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2332,12 +2332,28 @@ void cli_reset_error(struct cli_state *cli); /* The following definitions come from libsmb/clifile.c */ +struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + const char *oldname, + const char *newname); +NTSTATUS cli_posix_symlink_recv(struct tevent_req *req); +NTSTATUS cli_posix_symlink(struct cli_state *cli, + const char *oldname, + const char *newname); +struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + const char *oldname, + const char *newname); +NTSTATUS cli_posix_hardlink_recv(struct tevent_req *req); +NTSTATUS cli_posix_hardlink(struct cli_state *cli, + const char *oldname, + const char *newname); uint32_t unix_perms_to_wire(mode_t perms); mode_t wire_perms_to_unix(uint32_t perms); bool cli_unix_getfacl(struct cli_state *cli, const char *name, size_t *prb_size, char **retbuf); bool cli_unix_stat(struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbuf); -bool cli_unix_symlink(struct cli_state *cli, const char *oldname, const char *newname); -bool cli_unix_hardlink(struct cli_state *cli, const char *oldname, const char *newname); bool cli_unix_chmod(struct cli_state *cli, const char *fname, mode_t mode); bool cli_unix_chown(struct cli_state *cli, const char *fname, uid_t uid, gid_t gid); struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx, -- cgit From bccc7ee2c6456cdab08884b826ed5ddc2faf2a54 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 May 2009 21:51:15 -0700 Subject: Add cli_posix_readlink() and a torture test for it. Jeremy. --- source3/include/proto.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/include') diff --git a/source3/include/proto.h b/source3/include/proto.h index a918c29aaa..342c1432eb 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2341,6 +2341,15 @@ NTSTATUS cli_posix_symlink_recv(struct tevent_req *req); NTSTATUS cli_posix_symlink(struct cli_state *cli, const char *oldname, const char *newname); +struct tevent_req *cli_posix_readlink_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + const char *fname, + size_t len); +NTSTATUS cli_posix_readlink_recv(struct tevent_req *req, struct cli_state *cli, + char *retpath, size_t len); +NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname, + char *linkpath, size_t len); struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli, -- cgit