Introduce "struct stat_ex" as a replacement for SMB_STRUCT_STAT
authorVolker Lendecke <vl@samba.org>
Thu, 14 May 2009 13:34:42 +0000 (15:34 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 10 Mar 2010 12:14:37 +0000 (13:14 +0100)
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.

53 files changed:
source3/client/client.c
source3/client/clitar.c
source3/include/includes.h
source3/include/proto.h
source3/include/smb_macros.h
source3/lib/debug.c
source3/lib/system.c
source3/lib/time.c
source3/lib/util.c
source3/libsmb/clifile.c
source3/libsmb/clirap.c
source3/libsmb/libsmb_stat.c
source3/modules/nfs4_acls.c
source3/modules/vfs_acl_tdb.c
source3/modules/vfs_acl_xattr.c
source3/modules/vfs_afsacl.c
source3/modules/vfs_commit.c
source3/modules/vfs_default.c
source3/modules/vfs_fake_perms.c
source3/modules/vfs_fileid.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_hpuxacl.c
source3/modules/vfs_netatalk.c
source3/modules/vfs_recycle.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_streams_depot.c
source3/modules/vfs_streams_xattr.c
source3/modules/vfs_tsmsm.c
source3/param/loadparm.c
source3/passdb/pdb_smbpasswd.c
source3/printing/nt_printing.c
source3/printing/printfsp.c
source3/printing/printing.c
source3/registry/regfio.c
source3/smbd/close.c
source3/smbd/dir.c
source3/smbd/dosmode.c
source3/smbd/file_access.c
source3/smbd/fileio.c
source3/smbd/filename.c
source3/smbd/msdfs.c
source3/smbd/nttrans.c
source3/smbd/open.c
source3/smbd/posix_acls.c
source3/smbd/reply.c
source3/smbd/service.c
source3/smbd/trans2.c
source3/smbd/vfs.c
source3/torture/cmd_vfs.c
source3/utils/net_conf.c
source3/utils/net_usershare.c
source3/utils/testparm.c
source3/web/cgi.c

index b7065916b95676a3946f50407a81701e3b6e908d..71c3f44aeea587aaa45b9a5bd5f45fc0861d7d87 100644 (file)
@@ -3024,7 +3024,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");
@@ -3122,6 +3122,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");
@@ -3154,30 +3155,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 {
@@ -3185,7 +3187,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 {
@@ -3193,7 +3196,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 {
@@ -3402,7 +3406,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 {
index c9f3e87c4df2bd120f27afc878e0b9e7f2e5d66b..0ab0f26fa265b3ebb4601d1a63b503b8b08a4b05 100644 (file)
@@ -412,7 +412,7 @@ static void dotareof(int f)
        /* Could be a pipe, in which case S_ISREG should fail,
                * and we should write out at full size */
        if (tp > 0) {
-               size_t towrite = S_ISREG(stbuf.st_mode) ? tp : tbufsiz;
+               size_t towrite = S_ISREG(stbuf.st_ex_mode) ? tp : tbufsiz;
                if (sys_write(f, tarbuf, towrite) != towrite) {
                        DEBUG(0,("dotareof: sys_write fail\n"));
                }
@@ -1791,7 +1791,8 @@ int tar_parseargs(int argc, char *argv[], const char *Optarg, int Optind)
                                        SMB_STRUCT_STAT stbuf;
 
                                        if (sys_stat(argv[Optind], &stbuf) == 0) {
-                                               newer_than = stbuf.st_mtime;
+                                               newer_than = convert_timespec_to_time_t(
+                                                       stbuf.st_ex_mtime);
                                                DEBUG(1,("Getting files newer than %s",
                                                        time_to_asc(newer_than)));
                                                newOptind++;
index 922ec6bf1fa9cf28fe8f3d0edf72b80b31591b7d..fd5136716e171525db171b338e5476666901fadd 100644 (file)
@@ -428,13 +428,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.
index a0169a0e3421ad21b12d8199b4f5f805f10a73e1..b499e933a4d8940f739ed81a71a224ea3d7f8f17 100644 (file)
@@ -1020,13 +1020,6 @@ void srv_put_dos_date3(char *buf,int offset,time_t unixdate);
 void round_timespec(enum timestamp_set_resolution res, struct timespec *ts);
 void put_long_date_timespec(enum timestamp_set_resolution res, 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 srv_make_unix_date(const void *date_ptr);
 time_t srv_make_unix_date2(const void *date_ptr);
@@ -4185,7 +4178,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 );
@@ -6278,7 +6271,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);
index 22cfaaf58129a8d26223682b5ffb4ff699852ba2..7528883c2d9921ee4c9b53651bc298eb2609e25f 100644 (file)
@@ -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
index 14aca3adad2fd63d79bb4a7a4eee038d05b3eb0d..419af61ef3674d27ac75bc66cb399449e7ae6515 100644 (file)
@@ -739,7 +739,7 @@ void check_log_size( void )
 
        maxlog = lp_max_log_size() * 1024;
 
-       if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) {
+       if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_ex_size > maxlog ) {
                (void)reopen_logs();
                if( dbf && get_file_size( debugf ) > maxlog ) {
                        char *name = NULL;
index e8157662bfd4d99eb3177bc7eca85983cb698517..7ebfa4f9eaba4f2d00126dc114d66c91799ee75a 100644 (file)
@@ -290,6 +290,195 @@ int sys_fcntl_long(int fd, int cmd, long arg)
        return ret;
 }
 
+/****************************************************************************
+ Return the best approximation to a 'create time' under UNIX from a stat
+ structure.
+****************************************************************************/
+
+static time_t calc_create_time(const struct stat *st)
+{
+       time_t ret, ret1;
+
+       ret = MIN(st->st_ctime, st->st_mtime);
+       ret1 = MIN(ret, st->st_atime);
+
+       if(ret1 != (time_t)0) {
+               return ret1;
+       }
+
+       /*
+        * One of ctime, mtime or atime was zero (probably atime).
+        * Just return MIN(ctime, mtime).
+        */
+       return ret;
+}
+
+/****************************************************************************
+ Return the 'create time' from a stat struct if it exists (birthtime) or else
+ use the best approximation.
+****************************************************************************/
+
+static struct timespec get_create_timespec(const struct stat *pst)
+{
+       struct timespec ret;
+
+       if (S_ISDIR(pst->st_mode) && lp_fake_dir_create_times()) {
+               ret.tv_sec = 315493200L;          /* 1/1/1980 */
+               ret.tv_nsec = 0;
+               return ret;
+       }
+
+#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC)
+       ret = pst->st_birthtimespec;
+#elif defined(HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
+       ret.tv_sec = pst->st_birthtime;
+       ret.tv_nsec = pst->st_birthtimenspec;
+#elif defined(HAVE_STRUCT_STAT_ST_BIRTHTIME)
+       ret.tv_sec = pst->st_birthtime;
+       ret.tv_nsec = 0;
+#else
+       ret.tv_sec = calc_create_time(pst);
+       ret.tv_nsec = 0;
+#endif
+
+       /* Deal with systems that don't initialize birthtime correctly.
+        * Pointed out by SATOH Fumiyasu <fumiyas@osstech.jp>.
+        */
+       if (null_timespec(ret)) {
+               ret.tv_sec = calc_create_time(pst);
+               ret.tv_nsec = 0;
+       }
+       return ret;
+}
+
+/****************************************************************************
+ Get/Set all the possible time fields from a stat struct as a timespec.
+****************************************************************************/
+
+static struct timespec get_atimespec(const struct stat *pst)
+{
+#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
+       struct timespec ret;
+
+       /* Old system - no ns timestamp. */
+       ret.tv_sec = pst->st_atime;
+       ret.tv_nsec = 0;
+       return ret;
+#else
+#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
+       return pst->st_atim;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
+       struct timespec ret;
+       ret.tv_sec = pst->st_atime;
+       ret.tv_nsec = pst->st_atimensec;
+       return ret;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N)
+       struct timespec ret;
+       ret.tv_sec = pst->st_atime;
+       ret.tv_nsec = pst->st_atime_n;
+       return ret;
+#elif defined(HAVE_STRUCT_STAT_ST_UMTIME)
+       struct timespec ret;
+       ret.tv_sec = pst->st_atime;
+       ret.tv_nsec = pst->st_uatime * 1000;
+       return ret;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
+       return pst->st_atimespec;
+#else
+#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
+#endif
+#endif
+}
+
+static struct timespec get_mtimespec(const struct stat *pst)
+{
+#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
+       struct timespec ret;
+
+       /* Old system - no ns timestamp. */
+       ret.tv_sec = pst->st_mtime;
+       ret.tv_nsec = 0;
+       return ret;
+#else
+#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
+       return pst->st_mtim;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
+       struct timespec ret;
+       ret.tv_sec = pst->st_mtime;
+       ret.tv_nsec = pst->st_mtimensec;
+       return ret;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N)
+       struct timespec ret;
+       ret.tv_sec = pst->st_mtime;
+       ret.tv_nsec = pst->st_mtime_n;
+       return ret;
+#elif defined(HAVE_STRUCT_STAT_ST_UMTIME)
+       struct timespec ret;
+       ret.tv_sec = pst->st_mtime;
+       ret.tv_nsec = pst->st_umtime * 1000;
+       return ret;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
+       return pst->st_mtimespec;
+#else
+#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
+#endif
+#endif
+}
+
+static struct timespec get_ctimespec(const struct stat *pst)
+{
+#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
+       struct timespec ret;
+
+       /* Old system - no ns timestamp. */
+       ret.tv_sec = pst->st_ctime;
+       ret.tv_nsec = 0;
+       return ret;
+#else
+#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
+       return pst->st_ctim;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
+       struct timespec ret;
+       ret.tv_sec = pst->st_ctime;
+       ret.tv_nsec = pst->st_ctimensec;
+       return ret;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N)
+       struct timespec ret;
+       ret.tv_sec = pst->st_ctime;
+       ret.tv_nsec = pst->st_ctime_n;
+       return ret;
+#elif defined(HAVE_STRUCT_STAT_ST_UMTIME)
+       struct timespec ret;
+       ret.tv_sec = pst->st_ctime;
+       ret.tv_nsec = pst->st_uctime * 1000;
+       return ret;
+#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
+       return pst->st_ctimespec;
+#else
+#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT
+#endif
+#endif
+}
+
+static void init_stat_ex_from_stat (struct stat_ex *dst,
+                                   const struct stat *src)
+{
+       dst->st_ex_dev = src->st_dev;
+       dst->st_ex_ino = src->st_ino;
+       dst->st_ex_mode = src->st_mode;
+       dst->st_ex_nlink = src->st_nlink;
+       dst->st_ex_uid = src->st_uid;
+       dst->st_ex_gid = src->st_gid;
+       dst->st_ex_rdev = src->st_rdev;
+       dst->st_ex_size = src->st_size;
+       dst->st_ex_atime = get_atimespec(src);
+       dst->st_ex_mtime = get_mtimespec(src);
+       dst->st_ex_ctime = get_ctimespec(src);
+       dst->st_ex_btime = get_create_timespec(src);
+       dst->st_ex_blksize = src->st_blksize;
+       dst->st_ex_blocks = src->st_blocks;
+}
+
 /*******************************************************************
 A stat() wrapper that will deal with 64 bit filesizes.
 ********************************************************************/
@@ -300,10 +489,16 @@ int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf)
 #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_STAT64)
        ret = stat64(fname, sbuf);
 #else
-       ret = stat(fname, sbuf);
+       struct stat statbuf;
+       ret = stat(fname, &statbuf);
 #endif
-       /* we always want directories to appear zero size */
-       if (ret == 0 && S_ISDIR(sbuf->st_mode)) sbuf->st_size = 0;
+       if (ret == 0) {
+               /* we always want directories to appear zero size */
+               if (S_ISDIR(statbuf.st_mode)) {
+                       statbuf.st_size = 0;
+               }
+               init_stat_ex_from_stat(sbuf, &statbuf);
+       }
        return ret;
 }
 
@@ -317,10 +512,16 @@ int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf)
 #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_FSTAT64)
        ret = fstat64(fd, sbuf);
 #else
-       ret = fstat(fd, sbuf);
+       struct stat statbuf;
+       ret = fstat(fd, &statbuf);
 #endif
-       /* we always want directories to appear zero size */
-       if (ret == 0 && S_ISDIR(sbuf->st_mode)) sbuf->st_size = 0;
+       if (ret == 0) {
+               /* we always want directories to appear zero size */
+               if (S_ISDIR(statbuf.st_mode)) {
+                       statbuf.st_size = 0;
+               }
+               init_stat_ex_from_stat(sbuf, &statbuf);
+       }
        return ret;
 }
 
@@ -334,10 +535,16 @@ int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf)
 #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_LSTAT64)
        ret = lstat64(fname, sbuf);
 #else
-       ret = lstat(fname, sbuf);
+       struct stat statbuf;
+       ret = lstat(fname, &statbuf);
 #endif
-       /* we always want directories to appear zero size */
-       if (ret == 0 && S_ISDIR(sbuf->st_mode)) sbuf->st_size = 0;
+       if (ret == 0) {
+               /* we always want directories to appear zero size */
+               if (S_ISDIR(statbuf.st_mode)) {
+                       statbuf.st_size = 0;
+               }
+               init_stat_ex_from_stat(sbuf, &statbuf);
+       }
        return ret;
 }
 
index 839ebe94b20f2ffaaea1e5ef8b00e9248dbf070d..d48ab6811efa7a123366c21eda7a6a4c073830c0 100644 (file)
@@ -338,251 +338,6 @@ void put_long_date(char *p, time_t t)
        put_long_date_timespec(TIMESTAMP_SET_SECONDS, p, ts);
 }
 
-/****************************************************************************
- Return the best approximation to a 'create time' under UNIX from a stat
- structure.
-****************************************************************************/
-
-static time_t calc_create_time(const SMB_STRUCT_STAT *st)
-{
-       time_t ret, ret1;
-
-       ret = MIN(st->st_ctime, st->st_mtime);
-       ret1 = MIN(ret, st->st_atime);
-
-       if(ret1 != (time_t)0) {
-               return ret1;
-       }
-
-       /*
-        * One of ctime, mtime or atime was zero (probably atime).
-        * Just return MIN(ctime, mtime).
-        */
-       return ret;
-}
-
-/****************************************************************************
- Return the 'create time' from a stat struct if it exists (birthtime) or else
- use the best approximation.
-****************************************************************************/
-
-struct timespec get_create_timespec(const SMB_STRUCT_STAT *pst,bool fake_dirs)
-{
-       struct timespec ret;
-
-       if(S_ISDIR(pst->st_mode) && fake_dirs) {
-               ret.tv_sec = 315493200L;          /* 1/1/1980 */
-               ret.tv_nsec = 0;
-               return ret;
-       }
-
-#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC)
-       ret = pst->st_birthtimespec;
-#elif defined(HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
-       ret.tv_sec = pst->st_birthtime;
-       ret.tv_nsec = pst->st_birthtimenspec;
-#elif defined(HAVE_STRUCT_STAT_ST_BIRTHTIME)
-       ret.tv_sec = pst->st_birthtime;
-       ret.tv_nsec = 0;
-#else
-       ret.tv_sec = calc_create_time(pst);
-       ret.tv_nsec = 0;
-#endif
-
-       /* Deal with systems that don't initialize birthtime correctly.
-        * Pointed out by SATOH Fumiyasu <fumiyas@osstech.jp>.
-        */
-       if (null_timespec(ret)) {
-               ret.tv_sec = calc_create_time(pst);
-               ret.tv_nsec = 0;
-       }
-       return ret;
-}
-
-/****************************************************************************
- Get/Set all the possible time fields from a stat struct as a timespec.
-****************************************************************************/
-
-struct timespec get_atimespec(const SMB_STRUCT_STAT *pst)
-{
-#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
-       struct timespec ret;
-
-       /* Old system - no ns timestamp. */
-       ret.tv_sec = pst->st_atime;
-       ret.tv_nsec = 0;
-       return ret;
-#else
-#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
-       return pst->st_atim;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
-       struct timespec ret;
-       ret.tv_sec = pst->st_atime;
-       ret.tv_nsec = pst->st_atimensec;
-       return ret;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N)
-       struct timespec ret;
-       ret.tv_sec = pst->st_atime;
-       ret.tv_nsec = pst->st_atime_n;
-       return ret;
-#elif defined(HAVE_STRUCT_STAT_ST_UMTIME)
-       struct timespec ret;
-       ret.tv_sec = pst->st_atime;
-       ret.tv_nsec = pst->st_uatime * 1000;
-       return ret;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
-       return pst->st_atimespec;
-#else
-#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT 
-#endif
-#endif
-}
-
-void set_atimespec(SMB_STRUCT_STAT *pst, struct timespec ts)
-{
-#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
-       /* Old system - no ns timestamp. */
-       pst->st_atime = ts.tv_sec;
-#else
-#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
-       pst->st_atim = ts;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
-       pst->st_atime = ts.tv_sec;
-       pst->st_atimensec = ts.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N)
-       pst->st_atime = ts.tv_sec;
-       pst->st_atime_n = ts.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_UMTIME)
-       pst->st_atime = ts.tv_sec;
-       pst->st_uatime = ts.tv_nsec / 1000;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
-       pst->st_atimespec = ts;
-#else
-#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT 
-#endif
-#endif
-}
-
-struct timespec get_mtimespec(const SMB_STRUCT_STAT *pst)
-{
-#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
-       struct timespec ret;
-
-       /* Old system - no ns timestamp. */
-       ret.tv_sec = pst->st_mtime;
-       ret.tv_nsec = 0;
-       return ret;
-#else
-#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
-       return pst->st_mtim;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
-       struct timespec ret;
-       ret.tv_sec = pst->st_mtime;
-       ret.tv_nsec = pst->st_mtimensec;
-       return ret;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N)
-       struct timespec ret;
-       ret.tv_sec = pst->st_mtime;
-       ret.tv_nsec = pst->st_mtime_n;
-       return ret;
-#elif defined(HAVE_STRUCT_STAT_ST_UMTIME)
-       struct timespec ret;
-       ret.tv_sec = pst->st_mtime;
-       ret.tv_nsec = pst->st_umtime * 1000;
-       return ret;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
-       return pst->st_mtimespec;
-#else
-#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT 
-#endif
-#endif
-}
-
-void set_mtimespec(SMB_STRUCT_STAT *pst, struct timespec ts)
-{
-#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
-       /* Old system - no ns timestamp. */
-       pst->st_mtime = ts.tv_sec;
-#else
-#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
-       pst->st_mtim = ts;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
-       pst->st_mtime = ts.tv_sec;
-       pst->st_mtimensec = ts.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N)
-       pst->st_mtime = ts.tv_sec;
-       pst->st_mtime_n = ts.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_UMTIME)
-       pst->st_mtime = ts.tv_sec;
-       pst->st_umtime = ts.tv_nsec / 1000;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
-       pst->st_mtimespec = ts;
-#else
-#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT 
-#endif
-#endif
-}
-
-struct timespec get_ctimespec(const SMB_STRUCT_STAT *pst)
-{
-#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
-       struct timespec ret;
-
-       /* Old system - no ns timestamp. */
-       ret.tv_sec = pst->st_ctime;
-       ret.tv_nsec = 0;
-       return ret;
-#else
-#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
-       return pst->st_ctim;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
-       struct timespec ret;
-       ret.tv_sec = pst->st_ctime;
-       ret.tv_nsec = pst->st_ctimensec;
-       return ret;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N)
-       struct timespec ret;
-       ret.tv_sec = pst->st_ctime;
-       ret.tv_nsec = pst->st_ctime_n;
-       return ret;
-#elif defined(HAVE_STRUCT_STAT_ST_UMTIME)
-       struct timespec ret;
-       ret.tv_sec = pst->st_ctime;
-       ret.tv_nsec = pst->st_uctime * 1000;
-       return ret;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
-       return pst->st_ctimespec;
-#else
-#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT 
-#endif
-#endif
-}
-
-void set_ctimespec(SMB_STRUCT_STAT *pst, struct timespec ts)
-{
-#if !defined(HAVE_STAT_HIRES_TIMESTAMPS)
-       /* Old system - no ns timestamp. */
-       pst->st_ctime = ts.tv_sec;
-#else
-#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
-       pst->st_ctim = ts;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
-       pst->st_ctime = ts.tv_sec;
-       pst->st_ctimensec = ts.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIME_N)
-       pst->st_ctime = ts.tv_sec;
-       pst->st_ctime_n = ts.tv_nsec;
-#elif defined(HAVE_STRUCT_STAT_ST_UMTIME)
-       pst->st_ctime = ts.tv_sec;
-       pst->st_uctime = ts.tv_nsec / 1000;
-#elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
-       pst->st_ctimespec = ts;
-#else
-#error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT 
-#endif
-#endif
-}
-
 void dos_filetime_timespec(struct timespec *tsp)
 {
        tsp->tv_sec &= ~1;
index 3d7336f957bc62f3029781626710b53117861219..8ed288a129129a7c918980c75ac642f2e0539a07 100644 (file)
@@ -541,7 +541,7 @@ bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf)
        if (sys_stat(fname,sbuf) != 0) 
                return(False);
 
-       return((S_ISREG(sbuf->st_mode)) || (S_ISFIFO(sbuf->st_mode)));
+       return((S_ISREG(sbuf->st_ex_mode)) || (S_ISFIFO(sbuf->st_ex_mode)));
 }
 
 /*******************************************************************
@@ -554,7 +554,7 @@ bool socket_exist(const char *fname)
        if (sys_stat(fname,&st) != 0) 
                return(False);
 
-       return S_ISSOCK(st.st_mode);
+       return S_ISSOCK(st.st_ex_mode);
 }
 
 /*******************************************************************
@@ -572,7 +572,7 @@ bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st)
        if (sys_stat(dname,st) != 0) 
                return(False);
 
-       ret = S_ISDIR(st->st_mode);
+       ret = S_ISDIR(st->st_ex_mode);
        if(!ret)
                errno = ENOTDIR;
        return ret;
@@ -584,7 +584,7 @@ bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st)
 
 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf)
 {
-       return sbuf->st_size;
+       return sbuf->st_ex_size;
 }
 
 /*******************************************************************
@@ -594,7 +594,7 @@ uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf)
 SMB_OFF_T get_file_size(char *file_name)
 {
        SMB_STRUCT_STAT buf;
-       buf.st_size = 0;
+       buf.st_ex_size = 0;
        if(sys_stat(file_name,&buf) != 0)
                return (SMB_OFF_T)-1;
        return get_file_size_stat(&buf);
index d9fdfb692776f4b6c9aed693b80845c11d92ef55..0bb1e1aef89bce68cb0831ddb75f9dee6742f857 100644 (file)
@@ -294,31 +294,31 @@ bool cli_unix_stat(struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbu
                return false;
        }
 
-       sbuf->st_size = IVAL2_TO_SMB_BIG_UINT(rdata,0);     /* total size, in bytes */
-       sbuf->st_blocks = IVAL2_TO_SMB_BIG_UINT(rdata,8);   /* number of blocks allocated */
+       sbuf->st_ex_size = IVAL2_TO_SMB_BIG_UINT(rdata,0);     /* total size, in bytes */
+       sbuf->st_ex_blocks = IVAL2_TO_SMB_BIG_UINT(rdata,8);   /* number of blocks allocated */
 #if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
-       sbuf->st_blocks /= STAT_ST_BLOCKSIZE;
+       sbuf->st_ex_blocks /= STAT_ST_BLOCKSIZE;
 #else
        /* assume 512 byte blocks */
-       sbuf->st_blocks /= 512;
+       sbuf->st_ex_blocks /= 512;
 #endif
-       set_ctimespec(sbuf, interpret_long_date(rdata + 16));    /* time of last change */
-       set_atimespec(sbuf, interpret_long_date(rdata + 24));    /* time of last access */
-       set_mtimespec(sbuf, interpret_long_date(rdata + 32));    /* time of last modification */
+       sbuf->st_ex_ctime = interpret_long_date(rdata + 16);    /* time of last change */
+       sbuf->st_ex_atime = interpret_long_date(rdata + 24);    /* time of last access */
+       sbuf->st_ex_mtime = interpret_long_date(rdata + 32);    /* time of last modification */
 
-       sbuf->st_uid = (uid_t) IVAL(rdata,40);      /* user ID of owner */
-       sbuf->st_gid = (gid_t) IVAL(rdata,48);      /* group ID of owner */
-       sbuf->st_mode = unix_filetype_from_wire(IVAL(rdata, 56));
+       sbuf->st_ex_uid = (uid_t) IVAL(rdata,40);      /* user ID of owner */
+       sbuf->st_ex_gid = (gid_t) IVAL(rdata,48);      /* group ID of owner */
+       sbuf->st_ex_mode = unix_filetype_from_wire(IVAL(rdata, 56));
 #if defined(HAVE_MAKEDEV)
        {
-               uint32 dev_major = IVAL(rdata,60);
-               uint32 dev_minor = IVAL(rdata,68);
-               sbuf->st_rdev = makedev(dev_major, dev_minor);
+               uint32_t dev_major = IVAL(rdata,60);
+               uint32_t dev_minor = IVAL(rdata,68);
+               sbuf->st_ex_rdev = makedev(dev_major, dev_minor);
        }
 #endif
-       sbuf->st_ino = (SMB_INO_T)IVAL2_TO_SMB_BIG_UINT(rdata,76);      /* inode */
-       sbuf->st_mode |= wire_perms_to_unix(IVAL(rdata,84));     /* protection */
-       sbuf->st_nlink = IVAL(rdata,92);    /* number of hard links */
+       sbuf->st_ex_ino = (SMB_INO_T)IVAL2_TO_SMB_BIG_UINT(rdata,76);      /* inode */
+       sbuf->st_ex_mode |= wire_perms_to_unix(IVAL(rdata,84));     /* protection */
+       sbuf->st_ex_nlink = IVAL(rdata,92);    /* number of hard links */
 
        SAFE_FREE(rdata);
        SAFE_FREE(rparam);
index 2abb550ab2997f1bb280c5b62e64ddcf9aded8cc..3600a1d3018a299c88e92e766319f43cfc8a9d89 100644 (file)
@@ -1119,9 +1119,9 @@ bool cli_qpathinfo_basic( struct cli_state *cli, const char *name,
                return False;
        }
 
-       set_atimespec(sbuf, interpret_long_date( rdata+8 )); /* Access time. */
-       set_mtimespec(sbuf, interpret_long_date( rdata+16 )); /* Write time. */
-       set_ctimespec(sbuf, interpret_long_date( rdata+24 )); /* Change time. */
+       sbuf->st_ex_atime = interpret_long_date( rdata+8 ); /* Access time. */
+       sbuf->st_ex_mtime = interpret_long_date( rdata+16 ); /* Write time. */
+       sbuf->st_ex_ctime = interpret_long_date( rdata+24 ); /* Change time. */
 
        *attributes = IVAL( rdata, 32 );
 
index c2806daddb9294d6f8fdc653abbbd8248cdcebdc..56b7d17641056009d9af29f28296287c9727d789 100644 (file)
@@ -188,9 +188,9 @@ SMBC_stat_ctx(SMBCCTX *context,
         
        setup_stat(context, st, (char *) fname, size, mode);
         
-       set_atimespec(st, access_time_ts);
-       set_ctimespec(st, change_time_ts);
-       set_mtimespec(st, write_time_ts);
+       st->st_atime = convert_timespec_to_time_t(access_time_ts);
+       st->st_ctime = convert_timespec_to_time_t(change_time_ts);
+       st->st_mtime = convert_timespec_to_time_t(write_time_ts);
        st->st_dev   = srv->dev;
         
        TALLOC_FREE(frame);
@@ -293,9 +293,9 @@ SMBC_fstat_ctx(SMBCCTX *context,
         
        setup_stat(context, st, file->fname, size, mode);
         
-       set_atimespec(st, access_time_ts);
-       set_ctimespec(st, change_time_ts);
-       set_mtimespec(st, write_time_ts);
+       st->st_atime = convert_timespec_to_time_t(access_time_ts);
+       st->st_ctime = convert_timespec_to_time_t(change_time_ts);
+       st->st_mtime = convert_timespec_to_time_t(write_time_ts);
        st->st_dev = file->srv->dev;
         
        TALLOC_FREE(frame);
index e58b2945b8b082b4df886cf21b26b334dcf83770..13ed0f2f65510ca1baf53ce689124c3e718a75f1 100644 (file)
@@ -295,10 +295,11 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
                                                 * shouldn't alloc 0 for
                                                 * win */
 
-       uid_to_sid(&sid_owner, sbuf->st_uid);
-       gid_to_sid(&sid_group, sbuf->st_gid);
+       uid_to_sid(&sid_owner, sbuf->st_ex_uid);
+       gid_to_sid(&sid_group, sbuf->st_ex_gid);
 
-       if (smbacl4_nfs42win(mem_ctx, theacl, &sid_owner, &sid_group, S_ISDIR(sbuf->st_mode),
+       if (smbacl4_nfs42win(mem_ctx, theacl, &sid_owner, &sid_group,
+                            S_ISDIR(sbuf->st_ex_mode),
                                &nt_ace_list, &good_aces)==False) {
                DEBUG(8,("smbacl4_nfs42win failed\n"));
                return map_nt_error_from_unix(errno);
@@ -739,8 +740,8 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp,
                        DEBUG(8, ("unpack_nt_owners failed"));
                        return status;
                }
-               if (((newUID != (uid_t)-1) && (sbuf.st_uid != newUID)) ||
-                   ((newGID != (gid_t)-1) && (sbuf.st_gid != newGID))) {
+               if (((newUID != (uid_t)-1) && (sbuf.st_ex_uid != newUID)) ||
+                   ((newGID != (gid_t)-1) && (sbuf.st_ex_gid != newGID))) {
                        if(try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) {
                                DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n",
                                         fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, 
index a77f6d60f40a0b4f5a5bad63266a5352956d32a9..463250a9edb818e3158575743c013b9adf5c06cc 100644 (file)
@@ -414,8 +414,8 @@ static struct security_descriptor *default_file_sd(TALLOC_CTX *mem_ctx,
        struct security_ace *pace = NULL;
        struct security_acl *pacl = NULL;
 
-       uid_to_sid(&owner_sid, psbuf->st_uid);
-       gid_to_sid(&group_sid, psbuf->st_gid);
+       uid_to_sid(&owner_sid, psbuf->st_ex_uid);
+       gid_to_sid(&group_sid, psbuf->st_ex_gid);
 
        pace = TALLOC_ARRAY(mem_ctx, struct security_ace, 2);
        if (!pace) {
index 49e48998790872fa146188f36476c252fa3140ce..05156f84561c6e504d7f0186406808ad15b2ee0b 100644 (file)
@@ -282,8 +282,8 @@ static struct security_descriptor *default_file_sd(TALLOC_CTX *mem_ctx,
        struct security_ace *pace = NULL;
        struct security_acl *pacl = NULL;
 
-       uid_to_sid(&owner_sid, psbuf->st_uid);
-       gid_to_sid(&group_sid, psbuf->st_gid);
+       uid_to_sid(&owner_sid, psbuf->st_ex_uid);
+       gid_to_sid(&group_sid, psbuf->st_ex_gid);
 
        pace = TALLOC_ARRAY(mem_ctx, struct security_ace, 2);
        if (!pace) {
index 9588c2daf04bc00e533a4c60dd27abb42a11507f..814a131230163d761eb11a00d217e0bafb083430 100644 (file)
@@ -599,8 +599,8 @@ static size_t afs_to_nt_acl_common(struct afs_acl *afs_acl,
 
        struct afs_ace *afs_ace;
 
-       uid_to_sid(&owner_sid, psbuf->st_uid);
-       gid_to_sid(&group_sid, psbuf->st_gid);
+       uid_to_sid(&owner_sid, psbuf->st_ex_uid);
+       gid_to_sid(&group_sid, psbuf->st_ex_gid);
 
        if (afs_acl->num_aces) {
                nt_ace_list = TALLOC_ARRAY(mem_ctx, SEC_ACE, afs_acl->num_aces);
@@ -626,7 +626,7 @@ static size_t afs_to_nt_acl_common(struct afs_acl *afs_acl,
                        continue;
                }
 
-               if (S_ISDIR(psbuf->st_mode))
+               if (S_ISDIR(psbuf->st_ex_mode))
                        afs_to_nt_dir_rights(afs_ace->rights, &nt_rights,
                                             &flag);
                else
index a8105e021edb007bbda83be46ac481b2e98c558d..c22e8161d70d561987c51b2505e31fe62342a26f 100644 (file)
@@ -220,7 +220,7 @@ static int commit_open(
                 if (SMB_VFS_FSTAT(fsp, &st) == -1) {
                         return -1;
                 }
-               c->eof = st.st_size;
+               c->eof = st.st_ex_size;
         }
 
         return 0;
index f5cee4c5b576146da5a0f40e8b465f5e6036cef0..d456053d53eedb73abf54c3e9562f8581498daf3 100644 (file)
@@ -95,7 +95,6 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle)
        connection_struct *conn = handle->conn;
        uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
        SMB_STRUCT_STAT st;
-       struct timespec mtime_ts, ctime_ts, atime_ts;
        int ret = -1;
 
 #if defined(DARWINOS)
@@ -115,13 +114,9 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle)
                return caps;
        }
 
-       mtime_ts = get_mtimespec(&st);
-       ctime_ts = get_ctimespec(&st);
-       atime_ts = get_atimespec(&st);
-
-       if (mtime_ts.tv_nsec ||
-                       atime_ts.tv_nsec ||
-                       ctime_ts.tv_nsec) {
+       if (st.st_ex_mtime.tv_nsec ||
+                       st.st_ex_atime.tv_nsec ||
+                       st.st_ex_ctime.tv_nsec) {
                /* If any of the normal UNIX directory timestamps
                 * have a non-zero tv_nsec component assume
                 * we might be able to set sub-second timestamps.
@@ -478,7 +473,7 @@ static int copy_reg(const char *source, const char *dest)
        if (sys_lstat (source, &source_stats) == -1)
                return -1;
 
-       if (!S_ISREG (source_stats.st_mode))
+       if (!S_ISREG (source_stats.st_ex_mode))
                return -1;
 
        if((ifd = sys_open (source, O_RDONLY, 0)) < 0)
@@ -503,9 +498,9 @@ static int copy_reg(const char *source, const char *dest)
         */
 
 #ifdef HAVE_FCHOWN
-       if ((fchown(ofd, source_stats.st_uid, source_stats.st_gid) == -1) && (errno != EPERM))
+       if ((fchown(ofd, source_stats.st_ex_uid, source_stats.st_ex_gid) == -1) && (errno != EPERM))
 #else
-       if ((chown(dest, source_stats.st_uid, source_stats.st_gid) == -1) && (errno != EPERM))
+       if ((chown(dest, source_stats.st_ex_uid, source_stats.st_ex_gid) == -1) && (errno != EPERM))
 #endif
                goto err;
 
@@ -515,9 +510,9 @@ static int copy_reg(const char *source, const char *dest)
         */
 
 #if defined(HAVE_FCHMOD)
-       if (fchmod (ofd, source_stats.st_mode & 07777))
+       if (fchmod (ofd, source_stats.st_ex_mode & 07777))
 #else
-       if (chmod (dest, source_stats.st_mode & 07777))
+       if (chmod (dest, source_stats.st_ex_mode & 07777))
 #endif
                goto err;
 
@@ -531,8 +526,8 @@ static int copy_reg(const char *source, const char *dest)
        {
                struct utimbuf tv;
 
-               tv.actime = source_stats.st_atime;
-               tv.modtime = source_stats.st_mtime;
+               tv.actime = convert_timespec_to_time_t(source_stats.st_ex_atime);
+               tv.modtime = convert_timespec_to_time_t(source_stats.st_ex_mtime);
                utime(dest, &tv);
        }
 
@@ -623,13 +618,13 @@ static uint64_t vfswrap_get_alloc_size(vfs_handle_struct *handle,
 
        START_PROFILE(syscall_get_alloc_size);
 
-       if(S_ISDIR(sbuf->st_mode)) {
+       if(S_ISDIR(sbuf->st_ex_mode)) {
                result = 0;
                goto out;
        }
 
 #if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
-       result = (uint64_t)STAT_ST_BLOCKSIZE * (uint64_t)sbuf->st_blocks;
+       result = (uint64_t)STAT_ST_BLOCKSIZE * (uint64_t)sbuf->st_ex_blocks;
 #else
        result = get_file_size_stat(sbuf);
 #endif
@@ -825,18 +820,18 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
        if (SMB_VFS_FSTAT(fsp, &st) == -1)
                return -1;
 
-       space_to_write = len - st.st_size;
+       space_to_write = len - st.st_ex_size;
 
 #ifdef S_ISFIFO
-       if (S_ISFIFO(st.st_mode))
+       if (S_ISFIFO(st.st_ex_mode))
                return 0;
 #endif
 
-       if (st.st_size == len)
+       if (st.st_ex_size == len)
                return 0;
 
        /* Shrink - just ftruncate. */
-       if (st.st_size > len)
+       if (st.st_ex_size > len)
                return sys_ftruncate(fsp->fh->fd, len);
 
        /* available disk space is enough or not? */
@@ -854,10 +849,10 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
        }
 
        /* Write out the real space on disk. */
-       if (SMB_VFS_LSEEK(fsp, st.st_size, SEEK_SET) != st.st_size)
+       if (SMB_VFS_LSEEK(fsp, st.st_ex_size, SEEK_SET) != st.st_ex_size)
                return -1;
 
-       space_to_write = len - st.st_size;
+       space_to_write = len - st.st_ex_size;
 
        memset(zero_space, '\0', sizeof(zero_space));
        while ( space_to_write > 0) {
@@ -920,18 +915,18 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_O
        }
 
 #ifdef S_ISFIFO
-       if (S_ISFIFO(st.st_mode)) {
+       if (S_ISFIFO(st.st_ex_mode)) {
                result = 0;
                goto done;
        }
 #endif
 
-       if (st.st_size == len) {
+       if (st.st_ex_size == len) {
                result = 0;
                goto done;
        }
 
-       if (st.st_size > len) {
+       if (st.st_ex_size > len) {
                /* the sys_ftruncate should have worked */
                goto done;
        }
@@ -1099,8 +1094,8 @@ static struct file_id vfswrap_file_id_create(struct vfs_handle_struct *handle,
         * blob */
        ZERO_STRUCT(key);
 
-       key.devid = sbuf->st_dev;
-       key.inode = sbuf->st_ino;
+       key.devid = sbuf->st_ex_dev;
+       key.inode = sbuf->st_ex_ino;
        /* key.extid is unused by default. */
 
        return key;
@@ -1140,7 +1135,7 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
                return map_nt_error_from_unix(errno);
        }
 
-       if (S_ISDIR(sbuf.st_mode)) {
+       if (S_ISDIR(sbuf.st_ex_mode)) {
                goto done;
        }
 
@@ -1150,7 +1145,7 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
                return NT_STATUS_NO_MEMORY;
        }
 
-       streams->size = sbuf.st_size;
+       streams->size = sbuf.st_ex_size;
        streams->alloc_size = SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp, &sbuf);
 
        streams->name = talloc_strdup(streams, "::$DATA");
index 29893221471ecbfe3d90f257cfe96b143b2d69fe..cc3ab6220d0cb597cb6dbbcb83b1bce6904ee006 100644 (file)
@@ -32,13 +32,13 @@ static int fake_perms_stat(vfs_handle_struct *handle, const char *fname, SMB_STR
 
        ret = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
        if (ret == 0) {
-               if (S_ISDIR(sbuf->st_mode)) {
-                       sbuf->st_mode = S_IFDIR | S_IRWXU;
+               if (S_ISDIR(sbuf->st_ex_mode)) {
+                       sbuf->st_ex_mode = S_IFDIR | S_IRWXU;
                } else {
-                       sbuf->st_mode = S_IRWXU;
+                       sbuf->st_ex_mode = S_IRWXU;
                }
-               sbuf->st_uid = handle->conn->server_info->utok.uid;
-               sbuf->st_gid = handle->conn->server_info->utok.gid;
+               sbuf->st_ex_uid = handle->conn->server_info->utok.uid;
+               sbuf->st_ex_gid = handle->conn->server_info->utok.gid;
        }
 
        return ret;
@@ -50,13 +50,13 @@ static int fake_perms_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_ST
 
        ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
        if (ret == 0) {
-               if (S_ISDIR(sbuf->st_mode)) {
-                       sbuf->st_mode = S_IFDIR | S_IRWXU;
+               if (S_ISDIR(sbuf->st_ex_mode)) {
+                       sbuf->st_ex_mode = S_IFDIR | S_IRWXU;
                } else {
-                       sbuf->st_mode = S_IRWXU;
+                       sbuf->st_ex_mode = S_IRWXU;
                }
-               sbuf->st_uid = handle->conn->server_info->utok.uid;
-               sbuf->st_gid = handle->conn->server_info->utok.gid;
+               sbuf->st_ex_uid = handle->conn->server_info->utok.uid;
+               sbuf->st_ex_gid = handle->conn->server_info->utok.gid;
        }
        return ret;
 }
index 8152c5477e8e2ee93c9ee746df7ed95d92f5a8c8..93b71a4dc01dfd97fe851e5de488e23fa4cc5bc0 100644 (file)
@@ -237,8 +237,8 @@ static struct file_id fileid_file_id_create(struct vfs_handle_struct *handle,
                                struct fileid_handle_data,
                                return id);
 
-       id.devid        = data->device_mapping_fn(data, sbuf->st_dev);
-       id.inode        = sbuf->st_ino;
+       id.devid        = data->device_mapping_fn(data, sbuf->st_ex_dev);
+       id.inode        = sbuf->st_ex_ino;
 
        return id;
 }
index 59e4b313fa99c61af96ea97a434008ea8dacf299..26f96889092f02468aa892c8d3045ae3da45b54f 100644 (file)
@@ -846,7 +846,7 @@ static int vfs_gpfs_chmod(vfs_handle_struct *handle, const char *path, mode_t mo
                 }
 
                 /* avoid chmod() if possible, to preserve acls */
-                if ((st.st_mode & ~S_IFMT) == mode) {
+                if ((st.st_ex_mode & ~S_IFMT) == mode) {
                         return 0;
                 }
 
@@ -866,7 +866,7 @@ static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t
                 }
 
                 /* avoid chmod() if possible, to preserve acls */
-                if ((st.st_mode & ~S_IFMT) == mode) {
+                if ((st.st_ex_mode & ~S_IFMT) == mode) {
                         return 0;
                 }
 
index e75a9c64600cae9f6b66fd807c6d3c89970472c9..8c12970383918f1e10d04d8f33df0d2780c0b990 100644 (file)
@@ -258,7 +258,7 @@ int hpuxacl_sys_acl_set_file(vfs_handle_struct *handle,
                DEBUG(10, ("Error in stat call: %s\n", strerror(errno)));
                goto done;
        }
-       if (S_ISDIR(s.st_mode)) {
+       if (S_ISDIR(s.st_ex_mode)) {
                HPUX_ACL_T other_acl; 
                int other_count;
                SMB_ACL_TYPE_T other_type;
index e2fa0fb88a88fb1a015eed220e84cef480f6732b..ed3592235986f33e5c3a91432057183de20f5197 100644 (file)
@@ -82,7 +82,7 @@ static int atalk_build_paths(TALLOC_CTX *ctx, const char *path, const char *fnam
 
        sys_lstat(*orig_path, orig_info);
 
-       if (S_ISDIR(orig_info->st_mode)) {
+       if (S_ISDIR(orig_info->st_ex_mode)) {
                *adbl_path = talloc_asprintf(ctx, "%s/%s/%s/", 
                  path, &fname[ptr0], APPLEDOUBLE);
        } else {
@@ -242,7 +242,7 @@ static int atalk_rename(struct vfs_handle_struct *handle, const char *oldname, c
          &adbl_info, &orig_info) != 0)
                goto exit_rename;
 
-       if (S_ISDIR(orig_info.st_mode) || S_ISREG(orig_info.st_mode)) {
+       if (S_ISDIR(orig_info.st_ex_mode) || S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", adbl_path));              
                goto exit_rename;
        }
@@ -298,7 +298,7 @@ static int atalk_unlink(struct vfs_handle_struct *handle, const char *path)
          &adbl_info, &orig_info) != 0)
                goto exit_unlink;
 
-       if (S_ISDIR(orig_info.st_mode) || S_ISREG(orig_info.st_mode)) {
+       if (S_ISDIR(orig_info.st_ex_mode) || S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", adbl_path));
                goto exit_unlink;
        }
@@ -330,7 +330,7 @@ static int atalk_chmod(struct vfs_handle_struct *handle, const char *path, mode_
          &adbl_info, &orig_info) != 0)
                goto exit_chmod;
 
-       if (!S_ISDIR(orig_info.st_mode) && !S_ISREG(orig_info.st_mode)) {
+       if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", orig_path));              
                goto exit_chmod;
        }
@@ -362,7 +362,7 @@ static int atalk_chown(struct vfs_handle_struct *handle, const char *path, uid_t
          &adbl_info, &orig_info) != 0)
                goto exit_chown;
 
-       if (!S_ISDIR(orig_info.st_mode) && !S_ISREG(orig_info.st_mode)) {
+       if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", orig_path));              
                goto exit_chown;
        }
@@ -396,7 +396,7 @@ static int atalk_lchown(struct vfs_handle_struct *handle, const char *path, uid_
          &adbl_info, &orig_info) != 0)
                goto exit_lchown;
 
-       if (!S_ISDIR(orig_info.st_mode) && !S_ISREG(orig_info.st_mode)) {
+       if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", orig_path));              
                goto exit_lchown;
        }
index 2b0edcdb4a198aaa2a9ce382c694902b77e526f0..f1791aa6b17a4007bf999910ce8fbdc61141004e 100644 (file)
@@ -215,7 +215,7 @@ static bool recycle_directory_exist(vfs_handle_struct *handle, const char *dname
        SMB_STRUCT_STAT st;
 
        if (SMB_VFS_NEXT_STAT(handle, dname, &st) == 0) {
-               if (S_ISDIR(st.st_mode)) {
+               if (S_ISDIR(st.st_ex_mode)) {
                        return True;
                }
        }
@@ -228,7 +228,7 @@ static bool recycle_file_exist(vfs_handle_struct *handle, const char *fname)
        SMB_STRUCT_STAT st;
 
        if (SMB_VFS_NEXT_STAT(handle, fname, &st) == 0) {
-               if (S_ISREG(st.st_mode)) {
+               if (S_ISREG(st.st_ex_mode)) {
                        return True;
                }
        }
@@ -251,7 +251,7 @@ static SMB_OFF_T recycle_get_file_size(vfs_handle_struct *handle, const char *fn
                return (SMB_OFF_T)0;
        }
 
-       return(st.st_size);
+       return(st.st_ex_size);
 }
 
 /**
@@ -402,7 +402,7 @@ static void recycle_do_touch(vfs_handle_struct *handle, const char *fname,
                return;
        }
        ft.atime = timespec_current(); /* atime */
-       ft.mtime = touch_mtime ? ft.atime : get_mtimespec(&st); /* mtime */
+       ft.mtime = touch_mtime ? ft.atime : st.st_ex_mtime; /* mtime */
 
        become_root();
        ret = SMB_VFS_NEXT_NTIMES(handle, fname, &ft);
index 9543af32b9a9dc0e328b042aa6d1df790e618551..acfac57b51819a29414944e0ae106b07903dda91 100644 (file)
@@ -314,7 +314,7 @@ static void convert_sbuf(vfs_handle_struct *handle, const char *fname, SMB_STRUC
                if (shash == 0) {
                        shash = 1;
                }
-               sbuf->st_ino ^= shash;
+               sbuf->st_ex_ino ^= shash;
        }
 }
 
index e5a70b1a49978cc7d3ff4ca795a5030e2e070f18..72affe402ab3d0b4f9b0f17b9af6be2c37d35b9e 100644 (file)
@@ -182,7 +182,7 @@ static char *stream_dir(vfs_handle_struct *handle, const char *base_path,
        if (SMB_VFS_NEXT_STAT(handle, result, &sbuf) == 0) {
                char *newname;
 
-               if (!S_ISDIR(sbuf.st_mode)) {
+               if (!S_ISDIR(sbuf.st_ex_mode)) {
                        errno = EINVAL;
                        goto fail;
                }
@@ -504,7 +504,7 @@ static int streams_depot_unlink(vfs_handle_struct *handle,  const char *fname)
                return -1;
        }
 
-       if (sbuf.st_nlink == 1) {
+       if (sbuf.st_ex_nlink == 1) {
                char *dirname = stream_dir(handle, fname, &sbuf, false);
 
                if (dirname != NULL) {
@@ -652,7 +652,7 @@ static bool collect_one_stream(const char *dirname,
 
        if (!add_one_stream(state->mem_ctx,
                            &state->num_streams, &state->streams,
-                           dirent, sbuf.st_size,
+                           dirent, sbuf.st_ex_size,
                            SMB_VFS_GET_ALLOC_SIZE(state->handle->conn, NULL,
                                                   &sbuf))) {
                state->status = NT_STATUS_NO_MEMORY;
@@ -698,10 +698,10 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
        state.streams = NULL;
        state.num_streams = 0;
 
-       if (!S_ISDIR(sbuf.st_mode)) {
+       if (!S_ISDIR(sbuf.st_ex_mode)) {
                if (!add_one_stream(mem_ctx,
                                    &state.num_streams, &state.streams,
-                                   "::$DATA", sbuf.st_size,
+                                   "::$DATA", sbuf.st_ex_size,
                                    SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp,
                                                           &sbuf))) {
                        return NT_STATUS_NO_MEMORY;
index c5a7c697da263c4d9df082bc43558b6633bc66a7..ca39bb74e721146800d3873f064e372195ecfd5d 100644 (file)
@@ -42,17 +42,17 @@ static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
        char *upper_sname;
 
        DEBUG(10, ("stream_inode called for %lu/%lu [%s]\n",
-                  (unsigned long)sbuf->st_dev,
-                  (unsigned long)sbuf->st_ino, sname));
+                  (unsigned long)sbuf->st_ex_dev,
+                  (unsigned long)sbuf->st_ex_ino, sname));
 
        upper_sname = talloc_strdup_upper(talloc_tos(), sname);
        SMB_ASSERT(upper_sname != NULL);
 
         MD5Init(&ctx);
-        MD5Update(&ctx, (unsigned char *)&(sbuf->st_dev),
-                 sizeof(sbuf->st_dev));
-        MD5Update(&ctx, (unsigned char *)&(sbuf->st_ino),
-                 sizeof(sbuf->st_ino));
+        MD5Update(&ctx, (unsigned char *)&(sbuf->st_ex_dev),
+                 sizeof(sbuf->st_ex_dev));
+        MD5Update(&ctx, (unsigned char *)&(sbuf->st_ex_ino),
+                 sizeof(sbuf->st_ex_ino));
         MD5Update(&ctx, (unsigned char *)upper_sname,
                  talloc_get_size(upper_sname)-1);
         MD5Final(hash, &ctx);
@@ -159,18 +159,18 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
                return -1;
        }
 
-       sbuf->st_size = get_xattr_size(handle->conn, fsp->base_fsp,
+       sbuf->st_ex_size = get_xattr_size(handle->conn, fsp->base_fsp,
                                        io->base, io->xattr_name);
-       if (sbuf->st_size == -1) {
+       if (sbuf->st_ex_size == -1) {
                return -1;
        }
 
-       DEBUG(10, ("sbuf->st_size = %d\n", (int)sbuf->st_size));
+       DEBUG(10, ("sbuf->st_ex_size = %d\n", (int)sbuf->st_ex_size));
 
-       sbuf->st_ino = stream_inode(sbuf, io->xattr_name);
-       sbuf->st_mode &= ~S_IFMT;
-        sbuf->st_mode |= S_IFREG;
-        sbuf->st_blocks = sbuf->st_size % STAT_ST_BLOCKSIZE + 1;
+       sbuf->st_ex_ino = stream_inode(sbuf, io->xattr_name);
+       sbuf->st_ex_mode &= ~S_IFMT;
+        sbuf->st_ex_mode |= S_IFREG;
+        sbuf->st_ex_blocks = sbuf->st_ex_size % STAT_ST_BLOCKSIZE + 1;
 
        return 0;
 }
@@ -208,16 +208,16 @@ static int streams_xattr_stat(vfs_handle_struct *handle, const char *fname,
                goto fail;
        }
 
-       sbuf->st_size = get_xattr_size(handle->conn, NULL, base, xattr_name);
-       if (sbuf->st_size == -1) {
+       sbuf->st_ex_size = get_xattr_size(handle->conn, NULL, base, xattr_name);
+       if (sbuf->st_ex_size == -1) {
                errno = ENOENT;
                goto fail;
        }
 
-       sbuf->st_ino = stream_inode(sbuf, xattr_name);
-       sbuf->st_mode &= ~S_IFMT;
-        sbuf->st_mode |= S_IFREG;
-        sbuf->st_blocks = sbuf->st_size % STAT_ST_BLOCKSIZE + 1;
+       sbuf->st_ex_ino = stream_inode(sbuf, xattr_name);
+       sbuf->st_ex_mode &= ~S_IFMT;
+        sbuf->st_ex_mode |= S_IFREG;
+        sbuf->st_ex_blocks = sbuf->st_ex_size % STAT_ST_BLOCKSIZE + 1;
 
        result = 0;
  fail:
@@ -259,16 +259,16 @@ static int streams_xattr_lstat(vfs_handle_struct *handle, const char *fname,
                goto fail;
        }
 
-       sbuf->st_size = get_xattr_size(handle->conn, NULL, base, xattr_name);
-       if (sbuf->st_size == -1) {
+       sbuf->st_ex_size = get_xattr_size(handle->conn, NULL, base, xattr_name);
+       if (sbuf->st_ex_size == -1) {
                errno = ENOENT;
                goto fail;
        }
 
-       sbuf->st_ino = stream_inode(sbuf, xattr_name);
-       sbuf->st_mode &= ~S_IFMT;
-        sbuf->st_mode |= S_IFREG;
-        sbuf->st_blocks = sbuf->st_size % STAT_ST_BLOCKSIZE + 1;
+       sbuf->st_ex_ino = stream_inode(sbuf, xattr_name);
+       sbuf->st_ex_mode &= ~S_IFMT;
+        sbuf->st_ex_mode |= S_IFREG;
+        sbuf->st_ex_blocks = sbuf->st_ex_size % STAT_ST_BLOCKSIZE + 1;
 
        result = 0;
  fail:
@@ -740,10 +740,10 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
        state.streams = NULL;
        state.num_streams = 0;
 
-       if (!S_ISDIR(sbuf.st_mode)) {
+       if (!S_ISDIR(sbuf.st_ex_mode)) {
                if (!add_one_stream(mem_ctx,
                                    &state.num_streams, &state.streams,
-                                   "::$DATA", sbuf.st_size,
+                                   "::$DATA", sbuf.st_ex_size,
                                    SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp,
                                                           &sbuf))) {
                        return NT_STATUS_NO_MEMORY;
index 6fb1d1d2d46715a471e58b77511be9cd61eeef8f..57807105f6b3686969015cdb8a3b581796584dec 100644 (file)
@@ -153,10 +153,12 @@ static bool tsmsm_is_offline(struct vfs_handle_struct *handle,
 
         /* if the file has more than FILE_IS_ONLINE_RATIO of blocks available,
           then assume it is not offline (it may not be 100%, as it could be sparse) */
-       if (512 * (off_t)stbuf->st_blocks >= stbuf->st_size * tsmd->online_ratio) {
+       if (512 * (off_t)stbuf->st_ex_blocks >=
+           stbuf->st_ex_size * tsmd->online_ratio) {
                DEBUG(10,("%s not offline: st_blocks=%ld st_size=%ld "
-                         "online_ratio=%.2f\n", path, (long)stbuf->st_blocks,
-                         (long)stbuf->st_size, tsmd->online_ratio));
+                         "online_ratio=%.2f\n", path,
+                         (long)stbuf->st_ex_blocks,
+                         (long)stbuf->st_ex_size, tsmd->online_ratio));
                return false;
        }
 
@@ -254,9 +256,10 @@ static bool tsmsm_aio_force(struct vfs_handle_struct *handle, struct files_struc
        */
        if(SMB_VFS_FSTAT(fsp, &sbuf) == 0) {
                DEBUG(10,("tsmsm_aio_force st_blocks=%ld st_size=%ld "
-                         "online_ratio=%.2f\n", (long)sbuf.st_blocks,
-                         (long)sbuf.st_size, tsmd->online_ratio));
-               return !(512 * (off_t)sbuf.st_blocks >= sbuf.st_size * tsmd->online_ratio);
+                         "online_ratio=%.2f\n", (long)sbuf.st_ex_blocks,
+                         (long)sbuf.st_ex_size, tsmd->online_ratio));
+               return !(512 * (off_t)sbuf.st_ex_blocks >=
+                        sbuf.st_ex_size * tsmd->online_ratio);
        }
        return false;
 }
index 2ba2dd3e71b8fdb4374123f5b5571f0b46e4b9f1..c9d1b0b27c00130810f291fb6574474007c9a586 100644 (file)
@@ -350,6 +350,7 @@ struct global {
        int cups_connection_timeout;
        char *szSMBPerfcountModule;
        bool bMapUntrustedToDomain;
+       bool bFakeDirCreateTimes;
 };
 
 static struct global Globals;
@@ -361,7 +362,7 @@ struct service {
        bool valid;
        bool autoloaded;
        int usershare;
-       time_t usershare_last_mod;
+       struct timespec usershare_last_mod;
        char *szService;
        char *szPath;
        char *szUsername;
@@ -467,7 +468,6 @@ struct service {
        bool bDosFilemode;
        bool bDosFiletimes;
        bool bDosFiletimeResolution;
-       bool bFakeDirCreateTimes;
        bool bBlockingLocks;
        bool bInheritPerms;
        bool bInheritACLS;
@@ -505,7 +505,7 @@ static struct service sDefault = {
        True,                   /* valid */
        False,                  /* not autoloaded */
        0,                      /* not a usershare */
-       (time_t)0,              /* No last mod time */
+       {0, },                  /* No last mod time */
        NULL,                   /* szService */
        NULL,                   /* szPath */
        NULL,                   /* szUsername */
@@ -611,7 +611,6 @@ static struct service sDefault = {
        False,                  /* bDosFilemode */
        True,                   /* bDosFiletimes */
        False,                  /* bDosFiletimeResolution */
-       False,                  /* bFakeDirCreateTimes */
        True,                   /* bBlockingLocks */
        False,                  /* bInheritPerms */
        False,                  /* bInheritACLS */
@@ -4264,11 +4263,11 @@ static struct parm_struct parm_table[] = {
        {
                .label          = "fake directory create times",
                .type           = P_BOOL,
-               .p_class        = P_LOCAL,
-               .ptr            = &sDefault.bFakeDirCreateTimes,
+               .p_class        = P_GLOBAL,
+               .ptr            = &Globals.bFakeDirCreateTimes,
                .special        = NULL,
                .enum_list      = NULL,
-               .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
+               .flags          = FLAG_ADVANCED | FLAG_GLOBAL,
        },
        {
                .label          = "panic action",
@@ -5572,7 +5571,7 @@ FN_LOCAL_BOOL(lp_recursive_veto_delete, bDeleteVetoFiles)
 FN_LOCAL_BOOL(lp_dos_filemode, bDosFilemode)
 FN_LOCAL_BOOL(lp_dos_filetimes, bDosFiletimes)
 FN_LOCAL_BOOL(lp_dos_filetime_resolution, bDosFiletimeResolution)
-FN_LOCAL_BOOL(lp_fake_dir_create_times, bFakeDirCreateTimes)
+FN_GLOBAL_BOOL(lp_fake_dir_create_times, &Globals.bFakeDirCreateTimes)
 FN_LOCAL_BOOL(lp_blocking_locks, bBlockingLocks)
 FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
 FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
@@ -8322,27 +8321,27 @@ static void set_allowed_client_auth(void)
 
 static bool check_usershare_stat(const char *fname, SMB_STRUCT_STAT *psbuf)
 {
-       if (!S_ISREG(psbuf->st_mode)) {
+       if (!S_ISREG(psbuf->st_ex_mode)) {
                DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
                        "not a regular file\n",
-                       fname, (unsigned int)psbuf->st_uid ));
+                       fname, (unsigned int)psbuf->st_ex_uid ));
                return False;
        }
 
        /* Ensure this doesn't have the other write bit set. */
-       if (psbuf->st_mode & S_IWOTH) {
+       if (psbuf->st_ex_mode & S_IWOTH) {
                DEBUG(0,("check_usershare_stat: file %s owned by uid %u allows "
                        "public write. Refusing to allow as a usershare file.\n",
-                       fname, (unsigned int)psbuf->st_uid ));
+                       fname, (unsigned int)psbuf->st_ex_uid ));
                return False;
        }
 
        /* Should be 10k or less. */
-       if (psbuf->st_size > MAX_USERSHARE_FILE_SIZE) {
+       if (psbuf->st_ex_size > MAX_USERSHARE_FILE_SIZE) {
                DEBUG(0,("check_usershare_stat: file %s owned by uid %u is "
                        "too large (%u) to be a user share file.\n",
-                       fname, (unsigned int)psbuf->st_uid,
-                       (unsigned int)psbuf->st_size ));
+                       fname, (unsigned int)psbuf->st_ex_uid,
+                       (unsigned int)psbuf->st_ex_size ));
                return False;
        }
 
@@ -8501,7 +8500,7 @@ enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
 
        sys_closedir(dp);
 
-       if (!S_ISDIR(sbuf.st_mode)) {
+       if (!S_ISDIR(sbuf.st_ex_mode)) {
                DEBUG(2,("parse_usershare_file: share %s path %s is not a directory.\n",
                        servicename, sharepath ));
                return USERSHARE_PATH_NOT_DIRECTORY;
@@ -8513,7 +8512,7 @@ enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
 
        if (lp_usershare_owner_only()) {
                /* root can share anything. */
-               if ((psbuf->st_uid != 0) && (sbuf.st_uid != psbuf->st_uid)) {
+               if ((psbuf->st_ex_uid != 0) && (sbuf.st_ex_uid != psbuf->st_ex_uid)) {
                        return USERSHARE_PATH_NOT_ALLOWED;
                }
        }
@@ -8591,7 +8590,9 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
                TALLOC_FREE(canon_name);
        }
 
-       if (iService != -1 && ServicePtrs[iService]->usershare_last_mod == lsbuf.st_mtime) {
+       if (iService != -1 &&
+           timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
+                            &lsbuf.st_ex_mtime) == 0) {
                /* Nothing changed - Mark valid and return. */
                DEBUG(10,("process_usershare_file: service %s not changed.\n",
                        service_name ));
@@ -8624,7 +8625,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
        }
 
        /* Is it the same dev/inode as was lstated ? */
-       if (lsbuf.st_dev != sbuf.st_dev || lsbuf.st_ino != sbuf.st_ino) {
+       if (lsbuf.st_ex_dev != sbuf.st_ex_dev || lsbuf.st_ex_ino != sbuf.st_ex_ino) {
                close(fd);
                DEBUG(0,("process_usershare_file: fstat of %s is a different file from lstat. "
                        "Symlink spoofing going on ?\n", fname ));
@@ -8644,7 +8645,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
        close(fd);
        if (lines == NULL) {
                DEBUG(0,("process_usershare_file: loading file %s owned by %u failed.\n",
-                       fname, (unsigned int)sbuf.st_uid ));
+                       fname, (unsigned int)sbuf.st_ex_uid ));
                SAFE_FREE(fname);
                return -1;
        }
@@ -8708,7 +8709,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
        }
 
        /* And note when it was loaded. */
-       ServicePtrs[iService]->usershare_last_mod = sbuf.st_mtime;
+       ServicePtrs[iService]->usershare_last_mod = sbuf.st_ex_mtime;
        string_set(&ServicePtrs[iService]->szPath, sharepath);
        string_set(&ServicePtrs[iService]->comment, comment);
 
@@ -8721,7 +8722,7 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i
  Checks if a usershare entry has been modified since last load.
 ***************************************************************************/
 
-static bool usershare_exists(int iService, time_t *last_mod)
+static bool usershare_exists(int iService, struct timespec *last_mod)
 {
        SMB_STRUCT_STAT lsbuf;
        const char *usersharepath = Globals.szUsersharePath;
@@ -8738,13 +8739,13 @@ static bool usershare_exists(int iService, time_t *last_mod)
                return false;
        }
 
-       if (!S_ISREG(lsbuf.st_mode)) {
+       if (!S_ISREG(lsbuf.st_ex_mode)) {
                SAFE_FREE(fname);
                return false;
        }
 
        SAFE_FREE(fname);
-       *last_mod = lsbuf.st_mtime;
+       *last_mod = lsbuf.st_ex_mtime;
        return true;
 }
 
@@ -8769,7 +8770,7 @@ int load_usershare_service(const char *servicename)
                return -1;
        }
 
-       if (!S_ISDIR(sbuf.st_mode)) {
+       if (!S_ISDIR(sbuf.st_ex_mode)) {
                DEBUG(0,("load_usershare_service: %s is not a directory.\n",
                        usersharepath ));
                return -1;
@@ -8781,9 +8782,9 @@ int load_usershare_service(const char *servicename)
         */
 
 #ifdef S_ISVTX
-       if (sbuf.st_uid != 0 || !(sbuf.st_mode & S_ISVTX) || (sbuf.st_mode & S_IWOTH)) {
+       if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
 #else
-       if (sbuf.st_uid != 0 || (sbuf.st_mode & S_IWOTH)) {
+       if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
 #endif
                DEBUG(0,("load_usershare_service: directory %s is not owned by root "
                        "or does not have the sticky bit 't' set or is writable by anyone.\n",
@@ -8852,9 +8853,9 @@ int load_usershare_shares(void)
         */
 
 #ifdef S_ISVTX
-       if (sbuf.st_uid != 0 || !(sbuf.st_mode & S_ISVTX) || (sbuf.st_mode & S_IWOTH)) {
+       if (sbuf.st_ex_uid != 0 || !(sbuf.st_ex_mode & S_ISVTX) || (sbuf.st_ex_mode & S_IWOTH)) {
 #else
-       if (sbuf.st_uid != 0 || (sbuf.st_mode & S_IWOTH)) {
+       if (sbuf.st_ex_uid != 0 || (sbuf.st_ex_mode & S_IWOTH)) {
 #endif
                DEBUG(0,("load_usershare_shares: directory %s is not owned by root "
                        "or does not have the sticky bit 't' set or is writable by anyone.\n",
@@ -9255,7 +9256,7 @@ int lp_servicenumber(const char *pszServiceName)
        }
 
        if (iService >= 0 && ServicePtrs[iService]->usershare == USERSHARE_VALID) {
-               time_t last_mod;
+               struct timespec last_mod;
 
                if (!usershare_exists(iService, &last_mod)) {
                        /* Remove the share security tdb entry for it. */
@@ -9267,7 +9268,8 @@ int lp_servicenumber(const char *pszServiceName)
                }
 
                /* Has it been modified ? If so delete and reload. */
-               if (ServicePtrs[iService]->usershare_last_mod < last_mod) {
+               if (timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
+                                    &last_mod) < 0) {
                        /* Remove it from the array. */
                        free_service_byindex(iService);
                        /* and now reload it. */
index d663c7f0b2ffac7161adefa0dd21ccdfa9fa7ff3..8074b2e3a13c19517fa71c48442b0facdcaff504 100644 (file)
@@ -292,7 +292,7 @@ Error was %s\n", pfile, strerror(errno)));
                                return NULL;
                        }
 
-                       if( sbuf1.st_ino == sbuf2.st_ino) {
+                       if( sbuf1.st_ex_ino == sbuf2.st_ex_ino) {
                                /* No race. */
                                break;
                        }
index afb34061412cfd12830f88d44bda4bbce2396a7c..4d0c68e32a8c30ca52a5e68853fdfd5bf1505329 100644 (file)
@@ -1337,7 +1337,7 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
                        if (SMB_VFS_FSTAT(fsp, &st) == -1) {
                                 goto error_exit;
                        }
-                       old_create_time = st.st_mtime;
+                       old_create_time = convert_timespec_to_time_t(st.st_ex_mtime);
                        DEBUGADD(6,("file_version_is_newer: mod time = %ld sec\n",
                                (long)old_create_time));
                }
@@ -1389,7 +1389,7 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
                        if (SMB_VFS_FSTAT(fsp, &st) == -1) {
                                goto error_exit;
                        }
-                       new_create_time = st.st_mtime;
+                       new_create_time = convert_timespec_to_time_t(st.st_ex_mtime);
                        DEBUGADD(6,("file_version_is_newer: mod time = %ld sec\n",
                                (long)new_create_time));
                }
index 243b8ea03b7763538bcdb53427b1ca4daa624aba..a8e175a6845d0500b2ccffaa350cf0abcf4b2c88 100644 (file)
@@ -75,7 +75,7 @@ NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn,
        string_set(&fsp->fsp_name,print_job_fname(lp_const_servicename(SNUM(conn)),jobid));
        fsp->wcp = NULL;
        SMB_VFS_FSTAT(fsp, psbuf);
-       fsp->mode = psbuf->st_mode;
+       fsp->mode = psbuf->st_ex_mode;
        fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf);
 
        return NT_STATUS_OK;
index 10cd1d7dc6935ef100cc6651ef6b4ef719f49df3..a741c707c2d78e994e0c93a401be996e62dce513 100644 (file)
@@ -2564,7 +2564,7 @@ bool print_job_end(int snum, uint32 jobid, enum file_close_type close_type)
 
        if ((close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE) &&
                                (sys_fstat(pjob->fd, &sbuf) == 0)) {
-               pjob->size = sbuf.st_size;
+               pjob->size = sbuf.st_ex_size;
                close(pjob->fd);
                pjob->fd = -1;
        } else {
index e1c04c4777bb3f531b86e289cec636a1231a0903..af3feae4733a4cbbdd48360d13f751379d010098 100644 (file)
@@ -84,7 +84,7 @@ static int read_block( REGF_FILE *file, prs_struct *ps, uint32 file_offset, uint
                return -1;
        }
 
-       if ( (size_t)file_offset >= sbuf.st_size )
+       if ( (size_t)file_offset >= sbuf.st_ex_size )
                return -1;
        
        /* if block_size == 0, we are parsing HBIN records and need 
@@ -1434,7 +1434,7 @@ static REGF_HBIN* regf_hbin_allocate( REGF_FILE *file, uint32 block_size )
                return NULL;
        }
 
-       hbin->file_off       = sbuf.st_size;
+       hbin->file_off       = sbuf.st_ex_size;
 
        hbin->free_off       = HBIN_HEADER_REC_SIZE;
        hbin->free_size      = block_size - hbin->free_off + sizeof(uint32);;
index d23b509af2dd16d82cc7f2ca9c6c5eaa00c82049..9aab3a740535219da931f696d3f2764669e4541f 100644 (file)
@@ -103,7 +103,7 @@ static void check_magic(struct files_struct *fsp)
                return;
        }
 
-       transfer_file(tmp_fd,outfd,(SMB_OFF_T)st.st_size);
+       transfer_file(tmp_fd,outfd,(SMB_OFF_T)st.st_ex_size);
        close(tmp_fd);
        close(outfd);
        TALLOC_FREE(ctx);
index ab4a0d27e375a00c22eb4df8903bcd0f83a2f924..f5a9e22d1477d9c8c2c2d4cb40c97e93b8c648cd 100644 (file)
@@ -824,7 +824,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)
 {
@@ -910,8 +910,8 @@ bool get_dir_entry(TALLOC_CTX *ctx,
                                continue;
                        }
 
-                       *size = sbuf.st_size;
-                       *date = sbuf.st_mtime;
+                       *size = sbuf.st_ex_size;
+                       *date = sbuf.st_ex_mtime;
 
                        if (ask_sharemode) {
                                struct timespec write_time_ts;
@@ -920,7 +920,7 @@ bool get_dir_entry(TALLOC_CTX *ctx,
                                fileid = vfs_file_id_from_sbuf(conn, &sbuf);
                                get_file_infos(fileid, NULL, &write_time_ts);
                                if (!null_timespec(write_time_ts)) {
-                                       *date = convert_timespec_to_time_t(write_time_ts);
+                                       *date = write_time_ts;
                                }
                        }
 
@@ -989,7 +989,7 @@ static bool user_can_write_file(connection_struct *conn, char *name, SMB_STRUCT_
 
        /* Pseudo-open the file */
 
-       if(S_ISDIR(pst->st_mode)) {
+       if(S_ISDIR(pst->st_ex_mode)) {
                return True;
        }
 
@@ -1012,7 +1012,7 @@ static bool file_is_special(connection_struct *conn, char *name, SMB_STRUCT_STAT
 
        SMB_ASSERT(VALID_STAT(*pst));
 
-       if (S_ISREG(pst->st_mode) || S_ISDIR(pst->st_mode) || S_ISLNK(pst->st_mode))
+       if (S_ISREG(pst->st_ex_mode) || S_ISDIR(pst->st_ex_mode) || S_ISLNK(pst->st_ex_mode))
                return False;
 
        return True;
index 7b47fe62367100afd85efd5b6507af099fcd197e..ee293449cde7ebb247db08d325533f4cded0b036 100644 (file)
@@ -37,7 +37,7 @@ static uint32_t filter_mode_by_protocol(uint32_t mode)
 static int set_sparse_flag(const SMB_STRUCT_STAT * const sbuf)
 {
 #if defined (HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE)
-       if (sbuf->st_size > sbuf->st_blocks * (SMB_OFF_T)STAT_ST_BLOCKSIZE) {
+       if (sbuf->st_ex_size > sbuf->st_ex_blocks * (SMB_OFF_T)STAT_ST_BLOCKSIZE) {
                return FILE_ATTRIBUTE_SPARSE;
        }
 #endif
@@ -102,7 +102,7 @@ mode_t unix_mode(connection_struct *conn, int dosmode, const char *fname,
                }
 
                /* Save for later - but explicitly remove setuid bit for safety. */
-               dir_mode = sbuf.st_mode & ~S_ISUID;
+               dir_mode = sbuf.st_ex_mode & ~S_ISUID;
                DEBUG(2,("unix_mode(%s) inherit mode %o\n",fname,(int)dir_mode));
                /* Clear "result" */
                result = 0;
@@ -161,7 +161,7 @@ static uint32 dos_mode_from_sbuf(connection_struct *conn, const char *path, SMB_
 
        if (ro_opts == MAP_READONLY_YES) {
                /* Original Samba method - map inverse of user "w" bit. */
-               if ((sbuf->st_mode & S_IWUSR) == 0) {
+               if ((sbuf->st_ex_mode & S_IWUSR) == 0) {
                        result |= aRONLY;
                }
        } else if (ro_opts == MAP_READONLY_PERMISSIONS) {
@@ -171,16 +171,16 @@ static uint32 dos_mode_from_sbuf(connection_struct *conn, const char *path, SMB_
                }
        } /* Else never set the readonly bit. */
 
-       if (MAP_ARCHIVE(conn) && ((sbuf->st_mode & S_IXUSR) != 0))
+       if (MAP_ARCHIVE(conn) && ((sbuf->st_ex_mode & S_IXUSR) != 0))
                result |= aARCH;
 
-       if (MAP_SYSTEM(conn) && ((sbuf->st_mode & S_IXGRP) != 0))
+       if (MAP_SYSTEM(conn) && ((sbuf->st_ex_mode & S_IXGRP) != 0))
                result |= aSYSTEM;
        
-       if (MAP_HIDDEN(conn) && ((sbuf->st_mode & S_IXOTH) != 0))
+       if (MAP_HIDDEN(conn) && ((sbuf->st_ex_mode & S_IXOTH) != 0))
                result |= aHIDDEN;   
   
-       if (S_ISDIR(sbuf->st_mode))
+       if (S_ISDIR(sbuf->st_ex_mode))
                result = aDIR | (result & aRONLY);
 
        result |= set_sparse_flag(sbuf);
@@ -239,7 +239,7 @@ static bool get_ea_dos_attribute(connection_struct *conn, const char *path,SMB_S
                 return False;
         }
 
-       if (S_ISDIR(sbuf->st_mode)) {
+       if (S_ISDIR(sbuf->st_ex_mode)) {
                dosattr |= aDIR;
        }
        *pattr = (uint32)(dosattr & SAMBA_ATTRIBUTES_MASK);
@@ -426,7 +426,7 @@ static bool get_stat_dos_flags(connection_struct *conn,
                *dosmode |= aSYSTEM;
        if (sbuf->st_flags & UF_DOS_NOINDEX)
                *dosmode |= FILE_ATTRIBUTE_NONINDEXED;
-       if (S_ISDIR(sbuf->st_mode))
+       if (S_ISDIR(sbuf->st_ex_mode))
                *dosmode |= aDIR;
 
        *dosmode |= set_sparse_flag(sbuf);
@@ -528,7 +528,7 @@ uint32 dos_mode(connection_struct *conn, const char *path,SMB_STRUCT_STAT *sbuf)
 
        
        offline = SMB_VFS_IS_OFFLINE(conn, path, sbuf);
-       if (S_ISREG(sbuf->st_mode) && offline) {
+       if (S_ISREG(sbuf->st_ex_mode) && offline) {
                result |= FILE_ATTRIBUTE_OFFLINE;
        }
 
@@ -589,11 +589,11 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
                        return(-1);
        }
 
-       unixmode = st->st_mode;
+       unixmode = st->st_ex_mode;
 
-       get_acl_group_bits(conn, fname, &st->st_mode);
+       get_acl_group_bits(conn, fname, &st->st_ex_mode);
 
-       if (S_ISDIR(st->st_mode))
+       if (S_ISDIR(st->st_ex_mode))
                dosmode |= aDIR;
        else
                dosmode &= ~aDIR;
@@ -616,7 +616,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
        old_mode &= ~FILE_ATTRIBUTE_OFFLINE;
 
        if (old_mode == dosmode) {
-               st->st_mode = unixmode;
+               st->st_ex_mode = unixmode;
                return(0);
        }
 
@@ -631,7 +631,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
                                notify_fname(conn, NOTIFY_ACTION_MODIFIED,
                                    FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
                        }
-                       st->st_mode = unixmode;
+                       st->st_ex_mode = unixmode;
                        return 0;
                }
        }
@@ -643,7 +643,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
                        notify_fname(conn, NOTIFY_ACTION_MODIFIED,
                                FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
                }
-               st->st_mode = unixmode;
+               st->st_ex_mode = unixmode;
                return 0;
        }
 
@@ -665,10 +665,10 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
        if (!MAP_HIDDEN(conn))
                mask |= S_IXOTH;
 
-       unixmode |= (st->st_mode & mask);
+       unixmode |= (st->st_ex_mode & mask);
 
        /* if we previously had any r bits set then leave them alone */
-       if ((tmp = st->st_mode & (S_IRUSR|S_IRGRP|S_IROTH))) {
+       if ((tmp = st->st_ex_mode & (S_IRUSR|S_IRGRP|S_IROTH))) {
                unixmode &= ~(S_IRUSR|S_IRGRP|S_IROTH);
                unixmode |= tmp;
        }
@@ -676,7 +676,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
        /* if we previously had any w bits set then leave them alone 
                whilst adding in the new w bits, if the new mode is not rdonly */
        if (!IS_DOS_READONLY(dosmode)) {
-               unixmode |= (st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH));
+               unixmode |= (st->st_ex_mode & (S_IWUSR|S_IWGRP|S_IWOTH));
        }
 
        ret = SMB_VFS_CHMOD(conn, fname, unixmode);
@@ -685,7 +685,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
                        notify_fname(conn, NOTIFY_ACTION_MODIFIED,
                                     FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
                }
-               st->st_mode = unixmode;
+               st->st_ex_mode = unixmode;
                return 0;
        }
 
@@ -722,7 +722,7 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
                                FILE_NOTIFY_CHANGE_ATTRIBUTES, fname);
                }
                if (ret == 0) {
-                       st->st_mode = unixmode;
+                       st->st_ex_mode = unixmode;
                }
        }
 
index 1c0124ecbc51f3611c318477482066d1de8b18cc..9c77f9e96163fb3b811e062cda99d9ba9f32295f 100644 (file)
@@ -80,7 +80,7 @@ bool can_delete_file_in_directory(connection_struct *conn, const char *fname)
 
        /* fast paths first */
 
-       if (!S_ISDIR(sbuf.st_mode)) {
+       if (!S_ISDIR(sbuf.st_ex_mode)) {
                return False;
        }
        if (conn->server_info->utok.uid == 0 || conn->admin_user) {
@@ -91,7 +91,7 @@ bool can_delete_file_in_directory(connection_struct *conn, const char *fname)
 #ifdef S_ISVTX
        /* sticky bit means delete only by owner of file or by root or
         * by owner of directory. */
-       if (sbuf.st_mode & S_ISVTX) {
+       if (sbuf.st_ex_mode & S_ISVTX) {
                SMB_STRUCT_STAT sbuf_file;
                if(SMB_VFS_STAT(conn, fname, &sbuf_file) != 0) {
                        if (errno == ENOENT) {
@@ -112,8 +112,8 @@ bool can_delete_file_in_directory(connection_struct *conn, const char *fname)
                 * or the owner of the directory as we have no possible
                 * chance of deleting. Otherwise, go on and check the ACL.
                 */
-               if ((conn->server_info->utok.uid != sbuf.st_uid) &&
-                               (conn->server_info->utok.uid != sbuf_file.st_uid)) {
+               if ((conn->server_info->utok.uid != sbuf.st_ex_uid) &&
+                               (conn->server_info->utok.uid != sbuf_file.st_ex_uid)) {
                        DEBUG(10,("can_delete_file_in_directory: not "
                                "owner of file %s or directory %s",
                                fname, dname));
@@ -167,17 +167,17 @@ bool can_access_file_data(connection_struct *conn, const char *fname, SMB_STRUCT
        }
 
        /* Check primary owner access. */
-       if (conn->server_info->utok.uid == psbuf->st_uid) {
+       if (conn->server_info->utok.uid == psbuf->st_ex_uid) {
                switch (access_mask) {
                        case FILE_READ_DATA:
-                               return (psbuf->st_mode & S_IRUSR) ? True : False;
+                               return (psbuf->st_ex_mode & S_IRUSR) ? True : False;
 
                        case FILE_WRITE_DATA:
-                               return (psbuf->st_mode & S_IWUSR) ? True : False;
+                               return (psbuf->st_ex_mode & S_IWUSR) ? True : False;
 
                        default: /* FILE_READ_DATA|FILE_WRITE_DATA */
 
-                               if ((psbuf->st_mode & (S_IWUSR|S_IRUSR)) == (S_IWUSR|S_IRUSR)) {
+                               if ((psbuf->st_ex_mode & (S_IWUSR|S_IRUSR)) == (S_IWUSR|S_IRUSR)) {
                                        return True;
                                } else {
                                        return False;
index adf664b3960301da1713a81589b8b8e75a6f9307..de5f83c868f372e544998057731ad72da87ca319 100644 (file)
@@ -296,7 +296,7 @@ ssize_t write_file(struct smb_request *req,
                         */
 
                        if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && !wcp) {
-                               setup_write_cache(fsp, st.st_size);
+                               setup_write_cache(fsp, st.st_ex_size);
                                wcp = fsp->wcp;
                        }
                }
index e3acfc8483fa24573dbd839e5f4e742b0cc5c994..d8137989f66dc430a0e785d9dbda2db2640dd89b 100644 (file)
@@ -401,7 +401,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                         * It exists. it must either be a directory or this must
                         * be the last part of the path for it to be OK.
                         */
-                       if (end && !(st.st_mode & S_IFDIR)) {
+                       if (end && !S_ISDIR(st.st_ex_mode)) {
                                /*
                                 * An intermediate part of the name isn't
                                 * a directory.
index efbc05ceb00f332c96ddec132aac038e9364970f..422ed01a50a6a9f0268724927ece85e7c77631c7 100644 (file)
@@ -443,7 +443,7 @@ static bool is_msdfs_link_internal(TALLOC_CTX *ctx,
                goto err;
        }
 
-       if (!S_ISLNK(sbufp->st_mode)) {
+       if (!S_ISLNK(sbufp->st_ex_mode)) {
                DEBUG(5,("is_msdfs_link_read_target: %s is not a link.\n",
                                        path));
                goto err;
index 4bfbcd1690fab9108a6ed1110ff5ad10ced8fad4..74b28674aba3be155f1f865a585450cf8d0de894 100644 (file)
@@ -591,7 +591,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
                oplock_granted = NO_OPLOCK_RETURN;
        }
 
-       file_len = sbuf.st_size;
+       file_len = sbuf.st_ex_size;
        fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
        if (fattr == 0) {
                fattr = FILE_ATTRIBUTE_NORMAL;
@@ -625,10 +625,9 @@ void reply_ntcreate_and_X(struct smb_request *req)
        p += 4;
 
        /* Create time. */
-       c_timespec = get_create_timespec(
-               &sbuf,lp_fake_dir_create_times(SNUM(conn)));
-       a_timespec = get_atimespec(&sbuf);
-       m_timespec = get_mtimespec(&sbuf);
+       c_timespec = sbuf.st_ex_btime;
+       a_timespec = sbuf.st_ex_atime;
+       m_timespec = sbuf.st_ex_mtime;
 
        if (lp_dos_filetime_resolution(SNUM(conn))) {
                dos_filetime_timespec(&c_timespec);
@@ -1079,7 +1078,7 @@ static void call_nt_transact_create(connection_struct *conn,
                oplock_granted = NO_OPLOCK_RETURN;
        }
 
-       file_len = sbuf.st_size;
+       file_len = sbuf.st_ex_size;
        fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
        if (fattr == 0) {
                fattr = FILE_ATTRIBUTE_NORMAL;
@@ -1113,10 +1112,9 @@ static void call_nt_transact_create(connection_struct *conn,
        p += 8;
 
        /* Create time. */
-       c_timespec = get_create_timespec(
-               &sbuf,lp_fake_dir_create_times(SNUM(conn)));
-       a_timespec = get_atimespec(&sbuf);
-       m_timespec = get_mtimespec(&sbuf);
+       c_timespec = sbuf.st_ex_btime;
+       a_timespec = sbuf.st_ex_atime;
+       m_timespec = sbuf.st_ex_mtime;
 
        if (lp_dos_filetime_resolution(SNUM(conn))) {
                dos_filetime_timespec(&c_timespec);
@@ -1254,7 +1252,7 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
        }
 
        /* No links from a directory. */
-       if (S_ISDIR(sbuf1.st_mode)) {
+       if (S_ISDIR(sbuf1.st_ex_mode)) {
                return NT_STATUS_FILE_IS_A_DIRECTORY;
        }
 
@@ -1316,8 +1314,8 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
                return status;
        }
 
-       if (sbuf1.st_size) {
-               ret = vfs_transfer_file(fsp1, fsp2, sbuf1.st_size);
+       if (sbuf1.st_ex_size) {
+               ret = vfs_transfer_file(fsp1, fsp2, sbuf1.st_ex_size);
        }
 
        /*
@@ -1329,7 +1327,7 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
        close_file(NULL, fsp1, NORMAL_CLOSE);
 
        /* Ensure the modtime is set correctly on the destination file. */
-       set_close_write_time(fsp2, get_mtimespec(&sbuf1));
+       set_close_write_time(fsp2, sbuf1.st_ex_mtime);
 
        status = close_file(NULL, fsp2, NORMAL_CLOSE);
 
@@ -1342,7 +1340,7 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
        file_set_dosmode(conn, newname, fattr, &sbuf2, parent, false);
        TALLOC_FREE(parent);
 
-       if (ret < (SMB_OFF_T)sbuf1.st_size) {
+       if (ret < (SMB_OFF_T)sbuf1.st_ex_size) {
                return NT_STATUS_DISK_FULL;
        }
 
index ab3bf1ec757ecd89447c0a40ff4084b741449775..d6b37d4513d9ef6a2a62a20ac85368f1b9f8f9bc 100644 (file)
@@ -206,19 +206,19 @@ void change_file_owner_to_parent(connection_struct *conn,
        }
 
        become_root();
-       ret = SMB_VFS_FCHOWN(fsp, parent_st.st_uid, (gid_t)-1);
+       ret = SMB_VFS_FCHOWN(fsp, parent_st.st_ex_uid, (gid_t)-1);
        unbecome_root();
        if (ret == -1) {
                DEBUG(0,("change_file_owner_to_parent: failed to fchown "
                         "file %s to parent directory uid %u. Error "
                         "was %s\n", fsp->fsp_name,
-                        (unsigned int)parent_st.st_uid,
+                        (unsigned int)parent_st.st_ex_uid,
                         strerror(errno) ));
        }
 
        DEBUG(10,("change_file_owner_to_parent: changed new file %s to "
                  "parent directory uid %u.\n", fsp->fsp_name,
-                 (unsigned int)parent_st.st_uid ));
+                 (unsigned int)parent_st.st_ex_uid ));
 }
 
 NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
@@ -276,9 +276,9 @@ NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
        }
 
        /* Ensure we're pointing at the same place. */
-       if (sbuf.st_dev != psbuf->st_dev ||
-           sbuf.st_ino != psbuf->st_ino ||
-           sbuf.st_mode != psbuf->st_mode ) {
+       if (sbuf.st_ex_dev != psbuf->st_ex_dev ||
+           sbuf.st_ex_ino != psbuf->st_ex_ino ||
+           sbuf.st_ex_mode != psbuf->st_ex_mode ) {
                DEBUG(0,("change_dir_owner_to_parent: "
                         "device/inode/mode on directory %s changed. "
                         "Refusing to chown !\n", fname ));
@@ -287,20 +287,20 @@ NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
        }
 
        become_root();
-       ret = SMB_VFS_CHOWN(conn, ".", parent_st.st_uid, (gid_t)-1);
+       ret = SMB_VFS_CHOWN(conn, ".", parent_st.st_ex_uid, (gid_t)-1);
        unbecome_root();
        if (ret == -1) {
                status = map_nt_error_from_unix(errno);
                DEBUG(10,("change_dir_owner_to_parent: failed to chown "
                          "directory %s to parent directory uid %u. "
                          "Error was %s\n", fname,
-                         (unsigned int)parent_st.st_uid, strerror(errno) ));
+                         (unsigned int)parent_st.st_ex_uid, strerror(errno) ));
                goto out;
        }
 
        DEBUG(10,("change_dir_owner_to_parent: changed ownership of new "
                  "directory %s to parent directory uid %u.\n",
-                 fname, (unsigned int)parent_st.st_uid ));
+                 fname, (unsigned int)parent_st.st_ex_uid ));
 
  out:
 
@@ -396,7 +396,7 @@ static NTSTATUS open_file(files_struct *fsp,
                 * open flags. JRA.
                 */
 
-               if (file_existed && S_ISFIFO(psbuf->st_mode)) {
+               if (file_existed && S_ISFIFO(psbuf->st_ex_mode)) {
                        local_flags |= O_NONBLOCK;
                }
 #endif
@@ -498,7 +498,7 @@ static NTSTATUS open_file(files_struct *fsp,
                                        }
                                } else if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) &&
                                                        fsp->posix_open &&
-                                                       S_ISLNK(psbuf->st_mode)) {
+                                                       S_ISLNK(psbuf->st_ex_mode)) {
                                        /* This is a POSIX stat open for delete
                                         * or rename on a symlink that points
                                         * nowhere. Allow. */
@@ -543,13 +543,13 @@ static NTSTATUS open_file(files_struct *fsp,
         * so catch a directory open and return an EISDIR. JRA.
         */
 
-       if(S_ISDIR(psbuf->st_mode)) {
+       if(S_ISDIR(psbuf->st_ex_mode)) {
                fd_close(fsp);
                errno = EISDIR;
                return NT_STATUS_FILE_IS_A_DIRECTORY;
        }
 
-       fsp->mode = psbuf->st_mode;
+       fsp->mode = psbuf->st_ex_mode;
        fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf);
        fsp->vuid = req ? req->vuid : UID_FIELD_INVALID;
        fsp->file_pid = req ? req->smbpid : 0;
@@ -1592,7 +1592,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                                DEBUG(5,("open_file_ntcreate: FILE_CREATE "
                                         "requested for file %s and file "
                                         "already exists.\n", fname ));
-                               if (S_ISDIR(psbuf->st_mode)) {
+                               if (S_ISDIR(psbuf->st_ex_mode)) {
                                        errno = EISDIR;
                                } else {
                                        errno = EEXIST;
@@ -1619,13 +1619,13 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                             (create_disposition == FILE_OVERWRITE_IF))) {
                if (!open_match_attributes(conn, fname,
                                           existing_dos_attributes,
-                                          new_dos_attributes, psbuf->st_mode,
+                                          new_dos_attributes, psbuf->st_ex_mode,
                                           unx_mode, &new_unx_mode)) {
                        DEBUG(5,("open_file_ntcreate: attributes missmatch "
                                 "for file %s (%x %x) (0%o, 0%o)\n",
                                 fname, existing_dos_attributes,
                                 new_dos_attributes,
-                                (unsigned int)psbuf->st_mode,
+                                (unsigned int)psbuf->st_ex_mode,
                                 (unsigned int)unx_mode ));
                        errno = EACCES;
                        return NT_STATUS_ACCESS_DENIED;
@@ -1724,7 +1724,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
        }
 
        if (file_existed) {
-               struct timespec old_write_time = get_mtimespec(psbuf);
+               struct timespec old_write_time = psbuf->st_ex_mtime;
                id = vfs_file_id_from_sbuf(conn, psbuf);
 
                lck = get_share_mode_lock(talloc_tos(), id,
@@ -1928,7 +1928,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
        }
 
        if (!file_existed) {
-               struct timespec old_write_time = get_mtimespec(psbuf);
+               struct timespec old_write_time = psbuf->st_ex_mtime;
                /*
                 * Deal with the race condition where two smbd's detect the
                 * file doesn't exist and do the create at the same time. One
@@ -2143,7 +2143,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                                            new_dos_attributes | aARCH,
                                            &tmp_sbuf, parent_dir,
                                            true) == 0) {
-                                       unx_mode = tmp_sbuf.st_mode;
+                                       unx_mode = tmp_sbuf.st_ex_mode;
                                }
                        }
                }
@@ -2314,7 +2314,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                return map_nt_error_from_unix(errno);
        }
 
-       if (!S_ISDIR(psbuf->st_mode)) {
+       if (!S_ISDIR(psbuf->st_ex_mode)) {
                DEBUG(0, ("Directory just '%s' created is not a directory\n",
                          name));
                return NT_STATUS_ACCESS_DENIED;
@@ -2340,9 +2340,9 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                 * Consider bits automagically set by UNIX, i.e. SGID bit from parent
                 * dir.
                 */
-               if (mode & ~(S_IRWXU|S_IRWXG|S_IRWXO) && (mode & ~psbuf->st_mode)) {
+               if (mode & ~(S_IRWXU|S_IRWXG|S_IRWXO) && (mode & ~psbuf->st_ex_mode)) {
                        SMB_VFS_CHMOD(conn, name,
-                                     psbuf->st_mode | (mode & ~psbuf->st_mode));
+                                     psbuf->st_ex_mode | (mode & ~psbuf->st_ex_mode));
                }
        }
 
@@ -2484,7 +2484,7 @@ static NTSTATUS open_directory(connection_struct *conn,
                        return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if(!S_ISDIR(psbuf->st_mode)) {
+       if(!S_ISDIR(psbuf->st_ex_mode)) {
                DEBUG(5,("open_directory: %s is not a directory !\n",
                         fname ));
                return NT_STATUS_NOT_A_DIRECTORY;
@@ -2533,7 +2533,7 @@ static NTSTATUS open_directory(connection_struct *conn,
         * Setup the files_struct for it.
         */
        
-       fsp->mode = psbuf->st_mode;
+       fsp->mode = psbuf->st_ex_mode;
        fsp->file_id = vfs_file_id_from_sbuf(conn, psbuf);
        fsp->vuid = req ? req->vuid : UID_FIELD_INVALID;
        fsp->file_pid = req ? req->smbpid : 0;
@@ -2556,7 +2556,7 @@ static NTSTATUS open_directory(connection_struct *conn,
 
        string_set(&fsp->fsp_name,fname);
 
-       mtimespec = get_mtimespec(psbuf);
+       mtimespec = psbuf->st_ex_mtime;
 
        lck = get_share_mode_lock(talloc_tos(), fsp->file_id,
                                  conn->connectpath,
@@ -3171,7 +3171,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                }
        }
 
-       if (!fsp->is_directory && S_ISDIR(sbuf.st_mode)) {
+       if (!fsp->is_directory && S_ISDIR(sbuf.st_ex_mode)) {
                status = NT_STATUS_ACCESS_DENIED;
                goto fail;
        }
@@ -3179,7 +3179,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
        /* Save the requested allocation size. */
        if ((info == FILE_WAS_CREATED) || (info == FILE_WAS_OVERWRITTEN)) {
                if (allocation_size
-                   && (allocation_size > sbuf.st_size)) {
+                   && (allocation_size > sbuf.st_ex_size)) {
                        fsp->initial_allocation_size = smb_roundup(
                                fsp->conn, allocation_size);
                        if (fsp->is_directory) {
@@ -3194,7 +3194,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                        }
                } else {
                        fsp->initial_allocation_size = smb_roundup(
-                               fsp->conn, (uint64_t)sbuf.st_size);
+                               fsp->conn, (uint64_t)sbuf.st_ex_size);
                }
        }
 
index 43edf21f7d10359f371be39e2ec8a15d222b625e..e1ceea181b279eb61708bafdcf1104e81af54a6b 100644 (file)
@@ -905,8 +905,8 @@ static int map_acl_perms_to_permset(connection_struct *conn, mode_t mode, SMB_AC
 
 void create_file_sids(const SMB_STRUCT_STAT *psbuf, DOM_SID *powner_sid, DOM_SID *pgroup_sid)
 {
-       uid_to_sid( powner_sid, psbuf->st_uid );
-       gid_to_sid( pgroup_sid, psbuf->st_gid );
+       uid_to_sid( powner_sid, psbuf->st_ex_uid );
+       gid_to_sid( pgroup_sid, psbuf->st_ex_gid );
 }
 
 /****************************************************************************
@@ -1393,7 +1393,7 @@ static bool ensure_canon_entry_valid(canon_ace **pp_ace,
                ZERO_STRUCTP(pace);
                pace->type = SMB_ACL_USER_OBJ;
                pace->owner_type = UID_ACE;
-               pace->unix_ug.uid = pst->st_uid;
+               pace->unix_ug.uid = pst->st_ex_uid;
                pace->trustee = *pfile_owner_sid;
                pace->attr = ALLOW_ACE;
 
@@ -1423,7 +1423,7 @@ static bool ensure_canon_entry_valid(canon_ace **pp_ace,
 
                        apply_default_perms(params, is_directory, pace, S_IRUSR);
                } else {
-                       pace->perms = unix_perms_to_acl_perms(pst->st_mode, S_IRUSR, S_IWUSR, S_IXUSR);
+                       pace->perms = unix_perms_to_acl_perms(pst->st_ex_mode, S_IRUSR, S_IWUSR, S_IXUSR);
                }
 
                DLIST_ADD(*pp_ace, pace);
@@ -1438,7 +1438,7 @@ static bool ensure_canon_entry_valid(canon_ace **pp_ace,
                ZERO_STRUCTP(pace);
                pace->type = SMB_ACL_GROUP_OBJ;
                pace->owner_type = GID_ACE;
-               pace->unix_ug.uid = pst->st_gid;
+               pace->unix_ug.uid = pst->st_ex_gid;
                pace->trustee = *pfile_grp_sid;
                pace->attr = ALLOW_ACE;
                if (setting_acl) {
@@ -1449,7 +1449,7 @@ static bool ensure_canon_entry_valid(canon_ace **pp_ace,
                                pace->perms = 0;
                        apply_default_perms(params, is_directory, pace, S_IRGRP);
                } else {
-                       pace->perms = unix_perms_to_acl_perms(pst->st_mode, S_IRGRP, S_IWGRP, S_IXGRP);
+                       pace->perms = unix_perms_to_acl_perms(pst->st_ex_mode, S_IRGRP, S_IWGRP, S_IXGRP);
                }
 
                DLIST_ADD(*pp_ace, pace);
@@ -1471,7 +1471,7 @@ static bool ensure_canon_entry_valid(canon_ace **pp_ace,
                        pace->perms = 0;
                        apply_default_perms(params, is_directory, pace, S_IROTH);
                } else
-                       pace->perms = unix_perms_to_acl_perms(pst->st_mode, S_IROTH, S_IWOTH, S_IXOTH);
+                       pace->perms = unix_perms_to_acl_perms(pst->st_ex_mode, S_IROTH, S_IWOTH, S_IXOTH);
 
                DLIST_ADD(*pp_ace, pace);
        }
@@ -1649,7 +1649,7 @@ static bool create_canon_ace_lists(files_struct *fsp,
                        current_ace->type = SMB_ACL_OTHER;
                } else if (sid_equal(&current_ace->trustee, &global_sid_Creator_Owner)) {
                        current_ace->owner_type = UID_ACE;
-                       current_ace->unix_ug.uid = pst->st_uid;
+                       current_ace->unix_ug.uid = pst->st_ex_uid;
                        current_ace->type = SMB_ACL_USER_OBJ;
 
                        /*
@@ -1662,7 +1662,7 @@ static bool create_canon_ace_lists(files_struct *fsp,
                                psa->flags |= SEC_ACE_FLAG_INHERIT_ONLY;
                } else if (sid_equal(&current_ace->trustee, &global_sid_Creator_Group)) {
                        current_ace->owner_type = GID_ACE;
-                       current_ace->unix_ug.gid = pst->st_gid;
+                       current_ace->unix_ug.gid = pst->st_ex_gid;
                        current_ace->type = SMB_ACL_GROUP_OBJ;
 
                        /*
@@ -1677,7 +1677,7 @@ static bool create_canon_ace_lists(files_struct *fsp,
                        current_ace->owner_type = UID_ACE;
                        /* If it's the owning user, this is a user_obj, not
                         * a user. */
-                       if (current_ace->unix_ug.uid == pst->st_uid) {
+                       if (current_ace->unix_ug.uid == pst->st_ex_uid) {
                                current_ace->type = SMB_ACL_USER_OBJ;
                        } else {
                                current_ace->type = SMB_ACL_USER;
@@ -1686,7 +1686,7 @@ static bool create_canon_ace_lists(files_struct *fsp,
                        current_ace->owner_type = GID_ACE;
                        /* If it's the primary group, this is a group_obj, not
                         * a group. */
-                       if (current_ace->unix_ug.gid == pst->st_gid) {
+                       if (current_ace->unix_ug.gid == pst->st_ex_gid) {
                                current_ace->type = SMB_ACL_GROUP_OBJ;
                        } else {
                                current_ace->type = SMB_ACL_GROUP;
@@ -2296,7 +2296,7 @@ static bool unpack_canon_ace(files_struct *fsp,
         * A default 3 element mode entry for a directory should be rwx --- ---.
         */
 
-       pst->st_mode = create_default_mode(fsp, False);
+       pst->st_ex_mode = create_default_mode(fsp, False);
 
        if (!ensure_canon_entry_valid(&file_ace, fsp->conn->params, fsp->is_directory, pfile_owner_sid, pfile_grp_sid, pst, True)) {
                free_canon_ace_list(file_ace);
@@ -2312,7 +2312,7 @@ static bool unpack_canon_ace(files_struct *fsp,
         * it's a directory.
         */
 
-       pst->st_mode = create_default_mode(fsp, True);
+       pst->st_ex_mode = create_default_mode(fsp, True);
 
        if (dir_ace && !ensure_canon_entry_valid(&dir_ace, fsp->conn->params, fsp->is_directory, pfile_owner_sid, pfile_grp_sid, pst, True)) {
                free_canon_ace_list(file_ace);
@@ -2426,7 +2426,7 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
                        case SMB_ACL_USER_OBJ:
                                /* Get the SID from the owner. */
                                sid_copy(&sid, powner);
-                               unix_ug.uid = psbuf->st_uid;
+                               unix_ug.uid = psbuf->st_ex_uid;
                                owner_type = UID_ACE;
                                break;
                        case SMB_ACL_USER:
@@ -2443,7 +2443,7 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
                                         * entries out of the blue when setting ACLs, so a get/set
                                         * cycle will drop them.
                                         */
-                                       if (the_acl_type == SMB_ACL_TYPE_ACCESS && *puid == psbuf->st_uid) {
+                                       if (the_acl_type == SMB_ACL_TYPE_ACCESS && *puid == psbuf->st_ex_uid) {
                                                SMB_VFS_SYS_ACL_FREE_QUALIFIER(conn, (void *)puid,tagtype);
                                                continue;
                                        }
@@ -2456,7 +2456,7 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
                        case SMB_ACL_GROUP_OBJ:
                                /* Get the SID from the owning group. */
                                sid_copy(&sid, pgroup);
-                               unix_ug.gid = psbuf->st_gid;
+                               unix_ug.gid = psbuf->st_ex_gid;
                                owner_type = GID_ACE;
                                break;
                        case SMB_ACL_GROUP:
@@ -2510,7 +2510,7 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
         */
 
        if (!ensure_canon_entry_valid(&l_head, conn->params,
-                                     S_ISDIR(psbuf->st_mode), powner, pgroup,
+                                     S_ISDIR(psbuf->st_ex_mode), powner, pgroup,
                                      psbuf, False))
                goto fail;
 
@@ -2580,7 +2580,7 @@ static bool acl_group_override(connection_struct *conn,
 
        /* file primary group == user primary or supplementary group */
        if (lp_acl_group_control(SNUM(conn)) &&
-                       current_user_in_group(psbuf->st_gid)) {
+                       current_user_in_group(psbuf->st_ex_gid)) {
                return true;
        }
 
@@ -3119,7 +3119,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
                        goto done;
                }
 
-               if (S_ISDIR(sbuf->st_mode) && def_acl) {
+               if (S_ISDIR(sbuf->st_ex_mode) && def_acl) {
                        dir_ace = canonicalise_acl(conn, name, def_acl,
                                                   sbuf,
                                                   &global_sid_Creator_Owner,
@@ -3203,7 +3203,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
                                uint32_t acc = map_canon_ace_perms(SNUM(conn),
                                                &nt_acl_type,
                                                ace->perms,
-                                               S_ISDIR(sbuf->st_mode));
+                                               S_ISDIR(sbuf->st_ex_mode));
                                init_sec_ace(&nt_ace_list[num_aces++],
                                        &ace->trustee,
                                        nt_acl_type,
@@ -3224,7 +3224,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
                                uint32_t acc = map_canon_ace_perms(SNUM(conn),
                                                &nt_acl_type,
                                                ace->perms,
-                                               S_ISDIR(sbuf->st_mode));
+                                               S_ISDIR(sbuf->st_ex_mode));
                                init_sec_ace(&nt_ace_list[num_aces++],
                                        &ace->trustee,
                                        nt_acl_type,
@@ -3385,7 +3385,7 @@ NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
        posix_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, name, SMB_ACL_TYPE_ACCESS);
 
        /* If it's a directory get the default POSIX ACL. */
-       if(S_ISDIR(sbuf.st_mode)) {
+       if(S_ISDIR(sbuf.st_ex_mode)) {
                def_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, name, SMB_ACL_TYPE_DEFAULT);
                def_acl = free_empty_sys_acl(conn, def_acl);
        }
@@ -3733,7 +3733,7 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC
        }
 
        /* Save the original element we check against. */
-       orig_mode = sbuf.st_mode;
+       orig_mode = sbuf.st_ex_mode;
 
        /*
         * Unpack the user/group/world id's.
@@ -3750,7 +3750,7 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC
         * Noticed by Simo.
         */
 
-       if (((user != (uid_t)-1) && (sbuf.st_uid != user)) || (( grp != (gid_t)-1) && (sbuf.st_gid != grp))) {
+       if (((user != (uid_t)-1) && (sbuf.st_ex_uid != user)) || (( grp != (gid_t)-1) && (sbuf.st_ex_gid != grp))) {
 
                DEBUG(3,("set_nt_acl: chown %s. uid = %u, gid = %u.\n",
                                fsp->fsp_name, (unsigned int)user, (unsigned int)grp ));
@@ -3794,7 +3794,7 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC
                }
 
                /* Save the original element we check against. */
-               orig_mode = sbuf.st_mode;
+               orig_mode = sbuf.st_ex_mode;
 
                /* If we successfully chowned, we know we must
                 * be able to set the acl, so do it as root.
@@ -4334,7 +4334,7 @@ bool set_unix_posix_default_acl(connection_struct *conn, const char *fname, SMB_
 {
        SMB_ACL_T def_acl = NULL;
 
-       if (!S_ISDIR(psbuf->st_mode)) {
+       if (!S_ISDIR(psbuf->st_ex_mode)) {
                if (num_def_acls) {
                        DEBUG(5,("set_unix_posix_default_acl: Can't set default ACL on non-directory file %s\n", fname ));
                        errno = EISDIR;
index 23fa3e885b0c25bd662b82e312c91a8a17cc5fbd..b8bb275a9ff7d9171d6e8181ce3187497a1ab1d9 100644 (file)
@@ -938,7 +938,7 @@ void reply_checkpath(struct smb_request *req)
                }
        }
 
-       if (!S_ISDIR(sbuf.st_mode)) {
+       if (!S_ISDIR(sbuf.st_ex_mode)) {
                reply_botherror(req, NT_STATUS_NOT_A_DIRECTORY,
                                ERRDOS, ERRbadpath);
                END_PROFILE(SMBcheckpath);
@@ -1058,8 +1058,11 @@ void reply_getatr(struct smb_request *req)
                }
 
                mode = dos_mode(conn,fname,&sbuf);
-               size = sbuf.st_size;
-               mtime = sbuf.st_mtime;
+               size = sbuf.st_ex_size;
+               mtime = convert_timespec_to_time_t(sbuf.st_ex_mtime);
+               mode = dos_mode(conn, fname, &sbuf);
+               size = sbuf.st_ex_size;
+
                if (mode & aDIR) {
                        size = 0;
                }
@@ -1257,7 +1260,7 @@ void reply_search(struct smb_request *req)
        char *fname = NULL;
        SMB_OFF_T size;
        uint32 mode;
-       time_t date;
+       struct timespec date;
        uint32 dirtype;
        unsigned int numentries = 0;
        unsigned int maxentries = 0;
@@ -1468,7 +1471,7 @@ void reply_search(struct smb_request *req)
                                                fname,
                                                size,
                                                mode,
-                                               date,
+                                               convert_timespec_to_time_t(date),
                                                !allow_long_path_components)) {
                                        reply_nterror(req, NT_STATUS_NO_MEMORY);
                                        END_PROFILE(SMBsearch);
@@ -1688,9 +1691,9 @@ void reply_open(struct smb_request *req)
                return;
        }
 
-       size = sbuf.st_size;
+       size = sbuf.st_ex_size;
        fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
-       mtime = sbuf.st_mtime;
+       mtime = convert_timespec_to_time_t(sbuf.st_ex_mtime);
 
        if (fattr & aDIR) {
                DEBUG(3,("attempt to open a directory %s\n",fsp->fsp_name));
@@ -1852,11 +1855,11 @@ void reply_open_and_X(struct smb_request *req)
                        END_PROFILE(SMBopenX);
                        return;
                }
-               sbuf.st_size = SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf);
+               sbuf.st_ex_size = SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf);
        }
 
        fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
-       mtime = sbuf.st_mtime;
+       mtime = convert_timespec_to_time_t(sbuf.st_ex_mtime);
        if (fattr & aDIR) {
                close_file(req, fsp, ERROR_CLOSE);
                reply_doserror(req, ERRDOS, ERRnoaccess);
@@ -1905,7 +1908,7 @@ void reply_open_and_X(struct smb_request *req)
        } else {
                srv_put_dos_date3((char *)req->outbuf,smb_vwv4,mtime);
        }
-       SIVAL(req->outbuf,smb_vwv6,(uint32)sbuf.st_size);
+       SIVAL(req->outbuf,smb_vwv6,(uint32)sbuf.st_ex_size);
        SSVAL(req->outbuf,smb_vwv8,GET_OPENX_MODE(deny_mode));
        SSVAL(req->outbuf,smb_vwv11,smb_action);
 
@@ -2038,7 +2041,7 @@ void reply_mknew(struct smb_request *req)
                return;
        }
 
-       ft.atime = get_atimespec(&sbuf); /* atime. */
+       ft.atime = sbuf.st_ex_atime; /* atime. */
        status = smb_set_file_time(conn, fsp, fsp->fsp_name, &sbuf, &ft, true);
        if (!NT_STATUS_IS_OK(status)) {
                END_PROFILE(SMBcreate);
@@ -2225,7 +2228,7 @@ void reply_ctemp(struct smb_request *req)
 
        DEBUG( 2, ( "reply_ctemp: created temp file %s\n", fsp->fsp_name ) );
        DEBUG( 3, ( "reply_ctemp %s fd=%d umode=0%o\n", fsp->fsp_name,
-                   fsp->fh->fd, (unsigned int)sbuf.st_mode ) );
+                   fsp->fh->fd, (unsigned int)sbuf.st_ex_mode ) );
 
        END_PROFILE(SMBctemp);
        return;
@@ -2249,7 +2252,7 @@ static NTSTATUS can_rename(connection_struct *conn, files_struct *fsp,
                return NT_STATUS_NO_SUCH_FILE;
        }
 
-       if (S_ISDIR(pst->st_mode)) {
+       if (S_ISDIR(pst->st_ex_mode)) {
                if (fsp->posix_open) {
                        return NT_STATUS_OK;
                }
@@ -3019,7 +3022,7 @@ void reply_readbraw(struct smb_request *req)
        }
 
        if (SMB_VFS_FSTAT(fsp, &st) == 0) {
-               size = st.st_size;
+               size = st.st_ex_size;
        }
 
        if (startpos >= size) {
@@ -3308,8 +3311,8 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
                return;
        }
 
-       if (!S_ISREG(sbuf.st_mode) || (startpos > sbuf.st_size)
-           || (smb_maxcnt > (sbuf.st_size - startpos))) {
+       if (!S_ISREG(sbuf.st_ex_mode) || (startpos > sbuf.st_ex_size)
+           || (smb_maxcnt > (sbuf.st_ex_size - startpos))) {
                /*
                 * We already know that we would do a short read, so don't
                 * try the sendfile() path.
@@ -4354,7 +4357,7 @@ void reply_lseek(struct smb_request *req)
                                        return;
                                }
 
-                               current_pos += sbuf.st_size;
+                               current_pos += sbuf.st_ex_size;
                                if(current_pos < 0)
                                        res = SMB_VFS_LSEEK(fsp,0,SEEK_SET);
                        }
@@ -5197,7 +5200,7 @@ static bool recursive_rmdir(TALLOC_CTX *ctx,
                        break;
                }
 
-               if(st.st_mode & S_IFDIR) {
+               if(st.st_ex_mode & S_IFDIR) {
                        if(!recursive_rmdir(ctx, conn, fullname)) {
                                ret = False;
                                break;
@@ -5232,12 +5235,12 @@ NTSTATUS rmdir_internals(TALLOC_CTX *ctx,
                return map_nt_error_from_unix(errno);
        }
 
-       if (S_ISLNK(st.st_mode)) {
+       if (S_ISLNK(st.st_ex_mode)) {
                /* Is what it points to a directory ? */
                if(SMB_VFS_STAT(conn, directory, &st) != 0) {
                        return map_nt_error_from_unix(errno);
                }
-               if (!(S_ISDIR(st.st_mode))) {
+               if (!(S_ISDIR(st.st_ex_mode))) {
                        return NT_STATUS_NOT_A_DIRECTORY;
                }
                ret = SMB_VFS_UNLINK(conn,directory);
@@ -5314,7 +5317,7 @@ NTSTATUS rmdir_internals(TALLOC_CTX *ctx,
                        if(SMB_VFS_LSTAT(conn,fullname, &st) != 0) {
                                break;
                        }
-                       if(st.st_mode & S_IFDIR) {
+                       if(st.st_ex_mode & S_IFDIR) {
                                if(!recursive_rmdir(ctx, conn, fullname)) {
                                        break;
                                }
@@ -6001,7 +6004,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                        SMB_VFS_STAT(conn, directory, &sbuf1);
                }
 
-               if (S_ISDIR(sbuf1.st_mode)) {
+               if (S_ISDIR(sbuf1.st_ex_mode)) {
                        create_options |= FILE_DIRECTORY_FILE;
                }
 
@@ -6123,7 +6126,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
 
                create_options = 0;
 
-               if (S_ISDIR(sbuf1.st_mode)) {
+               if (S_ISDIR(sbuf1.st_ex_mode)) {
                        create_options |= FILE_DIRECTORY_FILE;
                }
 
@@ -6401,18 +6404,18 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                         * Stop the copy from occurring.
                         */
                        ret = -1;
-                       src_sbuf.st_size = 0;
+                       src_sbuf.st_ex_size = 0;
                }
        }
 
-       if (src_sbuf.st_size) {
-               ret = vfs_transfer_file(fsp1, fsp2, src_sbuf.st_size);
+       if (src_sbuf.st_ex_size) {
+               ret = vfs_transfer_file(fsp1, fsp2, src_sbuf.st_ex_size);
        }
 
        close_file(NULL, fsp1, NORMAL_CLOSE);
 
        /* Ensure the modtime is set correctly on the destination file. */
-       set_close_write_time(fsp2, get_mtimespec(&src_sbuf));
+       set_close_write_time(fsp2, src_sbuf.st_ex_mtime);
 
        /*
         * As we are opening fsp1 read-only we only expect
@@ -6426,7 +6429,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                return status;
        }
 
-       if (ret != (SMB_OFF_T)src_sbuf.st_size) {
+       if (ret != (SMB_OFF_T)src_sbuf.st_ex_size) {
                return NT_STATUS_DISK_FULL;
        }
 
@@ -7450,19 +7453,20 @@ void reply_getattrE(struct smb_request *req)
 
        reply_outbuf(req, 11, 0);
 
-       create_ts = get_create_timespec(&sbuf,
-                                 lp_fake_dir_create_times(SNUM(conn)));
+       create_ts = sbuf.st_ex_btime;
        srv_put_dos_date2((char *)req->outbuf, smb_vwv0, create_ts.tv_sec);
-       srv_put_dos_date2((char *)req->outbuf, smb_vwv2, sbuf.st_atime);
+       srv_put_dos_date2((char *)req->outbuf, smb_vwv2,
+                         convert_timespec_to_time_t(sbuf.st_ex_atime));
        /* Should we check pending modtime here ? JRA */
-       srv_put_dos_date2((char *)req->outbuf, smb_vwv4, sbuf.st_mtime);
+       srv_put_dos_date2((char *)req->outbuf, smb_vwv4,
+                         convert_timespec_to_time_t(sbuf.st_ex_mtime));
 
        if (mode & aDIR) {
                SIVAL(req->outbuf, smb_vwv6, 0);
                SIVAL(req->outbuf, smb_vwv8, 0);
        } else {
                uint32 allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,fsp, &sbuf);
-               SIVAL(req->outbuf, smb_vwv6, (uint32)sbuf.st_size);
+               SIVAL(req->outbuf, smb_vwv6, (uint32)sbuf.st_ex_size);
                SIVAL(req->outbuf, smb_vwv8, allocation_size);
        }
        SSVAL(req->outbuf,smb_vwv10, mode);
index 8490f17deaeffe88c69131867ca58974fb3ad37e..e63e83ba7d7a5442cb4fb5d3c4e96f34b5d8b1de 100644 (file)
@@ -1013,8 +1013,8 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
           I have disabled this chdir check (tridge) */
        /* the alternative is just to check the directory exists */
        if ((ret = SMB_VFS_STAT(conn, conn->connectpath, &st)) != 0 ||
-           !S_ISDIR(st.st_mode)) {
-               if (ret == 0 && !S_ISDIR(st.st_mode)) {
+           !S_ISDIR(st.st_ex_mode)) {
+               if (ret == 0 && !S_ISDIR(st.st_ex_mode)) {
                        DEBUG(0,("'%s' is not a directory, when connecting to "
                                 "[%s]\n", conn->connectpath,
                                 lp_servicename(snum)));
index e6d2b0ab8d2170515dfd0391aeb73cc4f846eed8..141868a9a763900b1b48409a01e62e805f12743a 100644 (file)
@@ -1013,8 +1013,8 @@ static void call_trans2open(connection_struct *conn,
 
        size = get_file_size_stat(&sbuf);
        fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
-       mtime = sbuf.st_mtime;
-       inode = sbuf.st_ino;
+       mtime = convert_timespec_to_time_t(sbuf.st_ex_mtime);
+       inode = sbuf.st_ex_ino;
        if (fattr & aDIR) {
                close_file(req, fsp, ERROR_CLOSE);
                reply_doserror(req, ERRDOS,ERRnoaccess);
@@ -1134,7 +1134,7 @@ static NTSTATUS unix_perms_from_wire( connection_struct *conn,
                if (!VALID_STAT(*psbuf)) {
                        return NT_STATUS_INVALID_PARAMETER;
                } else {
-                       *ret_perms = psbuf->st_mode;
+                       *ret_perms = psbuf->st_ex_mode;
                        return NT_STATUS_OK;
                }
        }
@@ -1205,7 +1205,7 @@ static bool check_msdfs_link(connection_struct *conn,
                DEBUG(5,("check_msdfs_link: Masquerading msdfs link %s "
                        "as a directory\n",
                        pathname));
-               psbuf->st_mode = (psbuf->st_mode & 0xFFF) | S_IFDIR;
+               psbuf->st_ex_mode = (psbuf->st_ex_mode & 0xFFF) | S_IFDIR;
                errno = saved_errno;
                return true;
        }
@@ -1414,10 +1414,9 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
                        }
                        allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,NULL,&sbuf);
 
-                       mdate_ts = get_mtimespec(&sbuf);
-                       adate_ts = get_atimespec(&sbuf);
-                       create_date_ts = get_create_timespec(&sbuf,
-                           lp_fake_dir_create_times(SNUM(conn)));
+                       mdate_ts = sbuf.st_ex_mtime;
+                       adate_ts = sbuf.st_ex_atime;
+                       create_date_ts = sbuf.st_ex_btime;
 
                        if (ask_sharemode) {
                                struct timespec write_time_ts;
@@ -1732,8 +1731,8 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
                                p +=4;
                        }
                        SIVAL(p,0,0); p += 4; /* Unknown - reserved ? */
-                       SIVAL(p,0,sbuf.st_ino); p += 4; /* FileIndexLow */
-                       SIVAL(p,0,sbuf.st_dev); p += 4; /* FileIndexHigh */
+                       SIVAL(p,0,sbuf.st_ex_ino); p += 4; /* FileIndexLow */
+                       SIVAL(p,0,sbuf.st_ex_dev); p += 4; /* FileIndexHigh */
                        len = srvstr_push(base_data, flags2, p,
                                          fname, PTR_DIFF(end_data, p),
                                          STR_TERMINATE_ASCII);
@@ -1788,8 +1787,8 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
                        }
                        p += 26;
                        SSVAL(p,0,0); p += 2; /* Reserved ? */
-                       SIVAL(p,0,sbuf.st_ino); p += 4; /* FileIndexLow */
-                       SIVAL(p,0,sbuf.st_dev); p += 4; /* FileIndexHigh */
+                       SIVAL(p,0,sbuf.st_ex_ino); p += 4; /* FileIndexLow */
+                       SIVAL(p,0,sbuf.st_ex_dev); p += 4; /* FileIndexHigh */
                        len = srvstr_push(base_data, flags2, p,
                                          fname, PTR_DIFF(end_data, p),
                                          STR_TERMINATE_ASCII);
@@ -2643,10 +2642,10 @@ static void call_trans2qfsinfo(connection_struct *conn,
                        sectors_per_unit = bsize/bytes_per_sector;
 
                        DEBUG(5,("call_trans2qfsinfo : SMB_INFO_ALLOCATION id=%x, bsize=%u, cSectorUnit=%u, \
-cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_dev, (unsigned int)bsize, (unsigned int)sectors_per_unit,
+cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (unsigned int)bsize, (unsigned int)sectors_per_unit,
                                (unsigned int)bytes_per_sector, (unsigned int)dsize, (unsigned int)dfree));
 
-                       SIVAL(pdata,l1_idFileSystem,st.st_dev);
+                       SIVAL(pdata,l1_idFileSystem,st.st_ex_dev);
                        SIVAL(pdata,l1_cSectorUnit,sectors_per_unit);
                        SIVAL(pdata,l1_cUnit,dsize);
                        SIVAL(pdata,l1_cUnitAvail,dfree);
@@ -2675,7 +2674,8 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_dev, (unsi
                        SCVAL(pdata,l2_vol_cch,len);
                        data_len = l2_vol_szVolLabel + len;
                        DEBUG(5,("call_trans2qfsinfo : time = %x, namelen = %d, name = %s\n",
-                               (unsigned)st.st_ctime, len, vname));
+                                (unsigned)convert_timespec_to_time_t(st.st_ex_ctime),
+                                len, vname));
                        break;
 
                case SMB_QUERY_FS_ATTRIBUTE_INFO:
@@ -3453,7 +3453,7 @@ static bool marshall_posix_acl(connection_struct *conn, char *pdata, SMB_STRUCT_
                switch (tagtype) {
                        case SMB_ACL_USER_OBJ:
                                SCVAL(pdata,0,SMB_POSIX_ACL_USER_OBJ);
-                               own_grp = (unsigned int)pst->st_uid;
+                               own_grp = (unsigned int)pst->st_ex_uid;
                                SIVAL(pdata,2,own_grp);
                                SIVAL(pdata,6,0);
                                break;
@@ -3473,7 +3473,7 @@ static bool marshall_posix_acl(connection_struct *conn, char *pdata, SMB_STRUCT_
                                }
                        case SMB_ACL_GROUP_OBJ:
                                SCVAL(pdata,0,SMB_POSIX_ACL_GROUP_OBJ);
-                               own_grp = (unsigned int)pst->st_gid;
+                               own_grp = (unsigned int)pst->st_ex_gid;
                                SIVAL(pdata,2,own_grp);
                                SIVAL(pdata,6,0);
                                break;
@@ -3522,7 +3522,7 @@ static char *store_file_unix_basic(connection_struct *conn,
                                const SMB_STRUCT_STAT *psbuf)
 {
        DEBUG(10,("store_file_unix_basic: SMB_QUERY_FILE_UNIX_BASIC\n"));
-       DEBUG(4,("store_file_unix_basic: st_mode=%o\n",(int)psbuf->st_mode));
+       DEBUG(4,("store_file_unix_basic: st_mode=%o\n",(int)psbuf->st_ex_mode));
 
        SOFF_T(pdata,0,get_file_size_stat(psbuf));             /* File size 64 Bit */
        pdata += 8;
@@ -3530,38 +3530,38 @@ static char *store_file_unix_basic(connection_struct *conn,
        SOFF_T(pdata,0,SMB_VFS_GET_ALLOC_SIZE(conn,fsp,psbuf)); /* Number of bytes used on disk - 64 Bit */
        pdata += 8;
 
-       put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata,get_ctimespec(psbuf));       /* Change Time 64 Bit */
-       put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata+8,get_atimespec(psbuf));     /* Last access time 64 Bit */
-       put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata+16,get_mtimespec(psbuf));    /* Last modification time 64 Bit */
+       put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata, psbuf->st_ex_ctime);       /* Change Time 64 Bit */
+       put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata+8, psbuf->st_ex_atime);     /* Last access time 64 Bit */
+       put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata+16,  psbuf->st_ex_mtime);    /* Last modification time 64 Bit */
        pdata += 24;
 
-       SIVAL(pdata,0,psbuf->st_uid);               /* user id for the owner */
+       SIVAL(pdata,0,psbuf->st_ex_uid);               /* user id for the owner */
        SIVAL(pdata,4,0);
        pdata += 8;
 
-       SIVAL(pdata,0,psbuf->st_gid);               /* group id of owner */
+       SIVAL(pdata,0,psbuf->st_ex_gid);               /* group id of owner */
        SIVAL(pdata,4,0);
        pdata += 8;
 
-       SIVAL(pdata,0,unix_filetype(psbuf->st_mode));
+       SIVAL(pdata,0,unix_filetype(psbuf->st_ex_mode));
        pdata += 4;
 
-       SIVAL(pdata,0,unix_dev_major(psbuf->st_rdev));   /* Major device number if type is device */
+       SIVAL(pdata,0,unix_dev_major(psbuf->st_ex_rdev));   /* Major device number if type is device */
        SIVAL(pdata,4,0);
        pdata += 8;
 
-       SIVAL(pdata,0,unix_dev_minor(psbuf->st_rdev));   /* Minor device number if type is device */
+       SIVAL(pdata,0,unix_dev_minor(psbuf->st_ex_rdev));   /* Minor device number if type is device */
        SIVAL(pdata,4,0);
        pdata += 8;
 
-       SINO_T_VAL(pdata,0,(SMB_INO_T)psbuf->st_ino);   /* inode number */
+       SINO_T_VAL(pdata,0,(SMB_INO_T)psbuf->st_ex_ino);   /* inode number */
        pdata += 8;
                                
-       SIVAL(pdata,0, unix_perms_to_wire(psbuf->st_mode));     /* Standard UNIX file permissions */
+       SIVAL(pdata,0, unix_perms_to_wire(psbuf->st_ex_mode));     /* Standard UNIX file permissions */
        SIVAL(pdata,4,0);
        pdata += 8;
 
-       SIVAL(pdata,0,psbuf->st_nlink);             /* number of hard links */
+       SIVAL(pdata,0,psbuf->st_ex_nlink);             /* number of hard links */
        SIVAL(pdata,4,0);
        pdata += 8;
 
@@ -3610,7 +3610,7 @@ static void map_info2_flags_from_sbuf(const SMB_STRUCT_STAT *psbuf,
 
        for (i = 0; i < ARRAY_SIZE(info2_flags_map); ++i) {
            *smb_fmask |= info2_flags_map[i].smb_fflag;
-           if (psbuf->st_flags & info2_flags_map[i].stat_fflag) {
+           if (psbuf->st_ex_flags & info2_flags_map[i].stat_fflag) {
                    *smb_fflags |= info2_flags_map[i].smb_fflag;
            }
        }
@@ -3626,7 +3626,7 @@ static bool map_info2_flags_to_sbuf(const SMB_STRUCT_STAT *psbuf,
        uint32 max_fmask = 0;
        int i;
 
-       *stat_fflags = psbuf->st_flags;
+       *stat_fflags = psbuf->st_ex_flags;
 
        /* For each flags requested in smb_fmask, check the state of the
         * corresponding flag in smb_fflags and set or clear the matching
@@ -3672,7 +3672,7 @@ static char *store_file_unix_basic_info2(connection_struct *conn,
        pdata = store_file_unix_basic(conn, pdata, fsp, psbuf);
 
        /* Create (birth) time 64 bit */
-       put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata, get_create_timespec(psbuf, False));
+       put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER, pdata, psbuf->st_ex_btime);
        pdata += 8;
 
        map_info2_flags_from_sbuf(psbuf, &file_flags, &flags_mask);
@@ -4081,7 +4081,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                mode = dos_mode(conn,fname,&sbuf);
        }
 
-       nlink = sbuf.st_nlink;
+       nlink = sbuf.st_ex_nlink;
 
        if (nlink && (mode&aDIR)) {
                nlink = 1;
@@ -4175,9 +4175,9 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
        dstart = pdata;
        dend = dstart + data_size - 1;
 
-       create_time_ts = get_create_timespec(&sbuf,lp_fake_dir_create_times(SNUM(conn)));
-       mtime_ts = get_mtimespec(&sbuf);
-       atime_ts = get_atimespec(&sbuf);
+       create_time_ts = sbuf.st_ex_btime;
+       mtime_ts = sbuf.st_ex_mtime;
+       atime_ts = sbuf.st_ex_atime;
 
        allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf);
 
@@ -4434,8 +4434,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                           BasicFileInformationTest. -tpot */
 
                        DEBUG(10,("call_trans2qfilepathinfo: SMB_FILE_INTERNAL_INFORMATION\n"));
-                       SIVAL(pdata,0,sbuf.st_ino); /* FileIndexLow */
-                       SIVAL(pdata,4,sbuf.st_dev); /* FileIndexHigh */
+                       SIVAL(pdata,0,sbuf.st_ex_ino); /* FileIndexLow */
+                       SIVAL(pdata,4,sbuf.st_ex_dev); /* FileIndexHigh */
                        data_size = 8;
                        break;
 
@@ -4604,7 +4604,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
 
                                DEBUG(10,("call_trans2qfilepathinfo: SMB_QUERY_FILE_UNIX_LINK\n"));
 #ifdef S_ISLNK
-                               if(!S_ISLNK(sbuf.st_mode)) {
+                               if(!S_ISLNK(sbuf.st_ex_mode)) {
                                        reply_unixerror(req, ERRSRV,
                                                        ERRbadlink);
                                        return;
@@ -4654,7 +4654,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                                        return;
                                }
 
-                               if (S_ISDIR(sbuf.st_mode)) {
+                               if (S_ISDIR(sbuf.st_ex_mode)) {
                                        if (fsp && fsp->is_directory) {
                                                def_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, fsp->fsp_name, SMB_ACL_TYPE_DEFAULT);
                                        } else {
@@ -4864,7 +4864,7 @@ NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
        }
 
        /* No links from a directory. */
-       if (S_ISDIR(sbuf1.st_mode)) {
+       if (S_ISDIR(sbuf1.st_ex_mode)) {
                return NT_STATUS_FILE_IS_A_DIRECTORY;
        }
 
@@ -4908,17 +4908,17 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
 
        /* get some defaults (no modifications) if any info is zero or -1. */
        if (null_timespec(ft->create_time)) {
-               ft->create_time = get_create_timespec(psbuf, lp_fake_dir_create_times(SNUM(conn)));
+               ft->create_time = psbuf->st_ex_btime;
                action &= ~FILE_NOTIFY_CHANGE_CREATION;
        }
 
        if (null_timespec(ft->atime)) {
-               ft->atime= get_atimespec(psbuf);
+               ft->atime= psbuf->st_ex_atime;
                action &= ~FILE_NOTIFY_CHANGE_LAST_ACCESS;
        }
 
        if (null_timespec(ft->mtime)) {
-               ft->mtime = get_mtimespec(psbuf);
+               ft->mtime = psbuf->st_ex_mtime;
                action &= ~FILE_NOTIFY_CHANGE_LAST_WRITE;
        }
 
@@ -4938,8 +4938,24 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
                time_to_asc(convert_timespec_to_time_t(ft->atime))));
        DEBUG(5,("smb_set_filetime: modtime: %s\n ",
                time_to_asc(convert_timespec_to_time_t(ft->mtime))));
-       DEBUG(5,("smb_set_file_time: createtime: %s\n ",
-               time_to_asc(convert_timespec_to_time_t(ft->create_time))));
+       if (!null_timespec(ft->create_time)) {
+               DEBUG(5,("smb_set_file_time: createtime: %s\n ",
+                  time_to_asc(convert_timespec_to_time_t(ft->create_time))));
+       }
+
+       /*
+        * Try and set the times of this file if
+        * they are different from the current values.
+        */
+
+       {
+               struct timespec mts = psbuf->st_ex_mtime;
+               struct timespec ats = psbuf->st_ex_atime;
+               if ((timespec_compare(&ft->atime, &ats) == 0) &&
+                   (timespec_compare(&ft->mtime, &mts) == 0)) {
+                       return NT_STATUS_OK;
+               }
+       }
 
        if (setting_write_time) {
                /*
@@ -4969,10 +4985,9 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
                }
        }
 
-       ft_stat.create_time = get_create_timespec(psbuf,
-                               lp_fake_dir_create_times(SNUM(conn)));
-       ft_stat.atime= get_atimespec(psbuf);
-       ft_stat.mtime = get_mtimespec(psbuf);
+       ft_stat.create_time = psbuf->st_ex_btime;
+       ft_stat.atime = psbuf->st_ex_atime;
+       ft_stat.mtime = psbuf->st_ex_mtime;
 
        round_timespec(conn->ts_res, &ft_stat.create_time);
        round_timespec(conn->ts_res, &ft_stat.atime);
@@ -5018,7 +5033,7 @@ static NTSTATUS smb_set_file_dosmode(connection_struct *conn,
        }
                
        if (dosmode) {
-               if (S_ISDIR(psbuf->st_mode)) {
+               if (S_ISDIR(psbuf->st_ex_mode)) {
                        dosmode |= aDIR;
                } else {
                        dosmode &= ~aDIR;
@@ -6049,7 +6064,7 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn,
        raw_unixmode = IVAL(pdata,84);
 
        if (VALID_STAT(*psbuf)) {
-               if (S_ISDIR(psbuf->st_mode)) {
+               if (S_ISDIR(psbuf->st_ex_mode)) {
                        ptype = PERM_EXISTING_DIR;
                } else {
                        ptype = PERM_EXISTING_FILE;
@@ -6086,8 +6101,8 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
                /* Ensure we don't try and change anything else. */
                raw_unixmode = SMB_MODE_NO_CHANGE;
                size = get_file_size_stat(psbuf);
-               ft.atime = get_atimespec(psbuf);
-               ft.mtime = get_mtimespec(psbuf);
+               ft.atime = psbuf->st_ex_atime;
+               ft.mtime = psbuf->st_ex_mtime;
                /* 
                 * We continue here as we might want to change the 
                 * owner uid/gid.
@@ -6121,13 +6136,13 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
         * Deal with the UNIX specific uid set.
         */
 
-       if ((set_owner != (uid_t)SMB_UID_NO_CHANGE) && (psbuf->st_uid != set_owner)) {
+       if ((set_owner != (uid_t)SMB_UID_NO_CHANGE) && (psbuf->st_ex_uid != set_owner)) {
                int ret;
 
                DEBUG(10,("smb_set_file_unix_basic: SMB_SET_FILE_UNIX_BASIC changing owner %u for path %s\n",
                        (unsigned int)set_owner, fname ));
 
-               if (S_ISLNK(psbuf->st_mode)) {
+               if (S_ISLNK(psbuf->st_ex_mode)) {
                        ret = SMB_VFS_LCHOWN(conn, fname, set_owner, (gid_t)-1);
                } else {
                        ret = SMB_VFS_CHOWN(conn, fname, set_owner, (gid_t)-1);
@@ -6146,7 +6161,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
         * Deal with the UNIX specific gid set.
         */
 
-       if ((set_grp != (uid_t)SMB_GID_NO_CHANGE) && (psbuf->st_gid != set_grp)) {
+       if ((set_grp != (uid_t)SMB_GID_NO_CHANGE) && (psbuf->st_ex_gid != set_grp)) {
                DEBUG(10,("smb_set_file_unix_basic: SMB_SET_FILE_UNIX_BASIC changing group %u for file %s\n",
                        (unsigned int)set_owner, fname ));
                if (SMB_VFS_CHOWN(conn, fname, (uid_t)-1, set_grp) != 0) {
index fd7f91f361fcba6563c63ff5586d45b6a327a8df..4eb3b3aa9107af29b91127e3b6e01fba78aff0a8 100644 (file)
@@ -341,7 +341,7 @@ bool vfs_directory_exist(connection_struct *conn, const char *dname, SMB_STRUCT_
        if (SMB_VFS_STAT(conn,dname,st) != 0)
                return(False);
 
-       ret = S_ISDIR(st->st_mode);
+       ret = S_ISDIR(st->st_ex_mode);
        if(!ret)
                errno = ENOTDIR;
 
@@ -381,7 +381,7 @@ bool vfs_file_exist(connection_struct *conn, const char *fname,SMB_STRUCT_STAT *
 
        if (SMB_VFS_STAT(conn,fname,sbuf) == -1)
                return False;
-       return(S_ISREG(sbuf->st_mode));
+       return(S_ISREG(sbuf->st_ex_mode));
 }
 
 /****************************************************************************
@@ -530,14 +530,14 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
        if (ret == -1)
                return ret;
 
-       if (len == (uint64_t)st.st_size)
+       if (len == (uint64_t)st.st_ex_size)
                return 0;
 
-       if (len < (uint64_t)st.st_size) {
+       if (len < (uint64_t)st.st_ex_size) {
                /* Shrink - use ftruncate. */
 
                DEBUG(10,("vfs_allocate_file_space: file %s, shrink. Current size %.0f\n",
-                               fsp->fsp_name, (double)st.st_size ));
+                               fsp->fsp_name, (double)st.st_ex_size ));
 
                contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_SHRINK);
 
@@ -559,7 +559,7 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
        if (!lp_strict_allocate(SNUM(fsp->conn)))
                return 0;
 
-       len -= st.st_size;
+       len -= st.st_ex_size;
        len /= 1024; /* Len is now number of 1k blocks needed. */
        space_avail = get_dfree_info(conn,fsp->fsp_name,False,&bsize,&dfree,&dsize);
        if (space_avail == (uint64_t)-1) {
@@ -567,7 +567,7 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
        }
 
        DEBUG(10,("vfs_allocate_file_space: file %s, grow. Current size %.0f, needed blocks = %.0f, space avail = %.0f\n",
-                       fsp->fsp_name, (double)st.st_size, (double)len, (double)space_avail ));
+                       fsp->fsp_name, (double)st.st_ex_size, (double)len, (double)space_avail ));
 
        if (len > space_avail) {
                errno = ENOSPC;
@@ -627,12 +627,12 @@ int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len)
                return ret;
        }
 
-       if (len <= st.st_size) {
+       if (len <= st.st_ex_size) {
                return 0;
        }
 
        DEBUG(10,("vfs_fill_sparse: write zeros in file %s from len %.0f to len %.0f (%.0f bytes)\n",
-               fsp->fsp_name, (double)st.st_size, (double)len, (double)(len - st.st_size)));
+               fsp->fsp_name, (double)st.st_ex_size, (double)len, (double)(len - st.st_ex_size)));
 
        contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_FILL_SPARSE);
 
@@ -647,8 +647,8 @@ int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len)
                }
        }
 
-       offset = st.st_size;
-       num_to_write = len - st.st_size;
+       offset = st.st_ex_size;
+       num_to_write = len - st.st_ex_size;
        total = 0;
 
        while (total < num_to_write) {
@@ -804,8 +804,8 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
                   && (cache_value.data[cache_value.length-1] == '\0'));
 
        if ((SMB_VFS_STAT(conn, (char *)cache_value.data, &st2) == 0)
-           && (st.st_dev == st2.st_dev) && (st.st_ino == st2.st_ino)
-           && (S_ISDIR(st.st_mode))) {
+           && (st.st_ex_dev == st2.st_ex_dev) && (st.st_ex_ino == st2.st_ex_ino)
+           && (S_ISDIR(st.st_ex_mode))) {
                /*
                 * Ok, we're done
                 */
@@ -961,7 +961,7 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
         if (!lp_symlinks(SNUM(conn))) {
                 SMB_STRUCT_STAT statbuf;
                 if ( (SMB_VFS_LSTAT(conn,fname,&statbuf) != -1) &&
-                                (S_ISLNK(statbuf.st_mode)) ) {
+                                (S_ISLNK(statbuf.st_ex_mode)) ) {
                        if (free_resolved_name) {
                                SAFE_FREE(resolved_name);
                        }
index 80ee3ec0e8fb7f3ce700de958b853f638bf04aee..1664f9a94d1b41db65173391e7399eca9b54d59f 100644 (file)
@@ -157,31 +157,35 @@ static NTSTATUS cmd_readdir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc
 
        printf("readdir: %s\n", dent->d_name);
        if (VALID_STAT(st)) {
+               time_t tmp_time;
                printf("  stat available");
-               if (S_ISREG(st.st_mode)) printf("  Regular File\n");
-               else if (S_ISDIR(st.st_mode)) printf("  Directory\n");
-               else if (S_ISCHR(st.st_mode)) printf("  Character Device\n");
-               else if (S_ISBLK(st.st_mode)) printf("  Block Device\n");
-               else if (S_ISFIFO(st.st_mode)) printf("  Fifo\n");
-               else if (S_ISLNK(st.st_mode)) printf("  Symbolic Link\n");
-               else if (S_ISSOCK(st.st_mode)) printf("  Socket\n");
-               printf("  Size: %10u", (unsigned int)st.st_size);
+               if (S_ISREG(st.st_ex_mode)) printf("  Regular File\n");
+               else if (S_ISDIR(st.st_ex_mode)) printf("  Directory\n");
+               else if (S_ISCHR(st.st_ex_mode)) printf("  Character Device\n");
+               else if (S_ISBLK(st.st_ex_mode)) printf("  Block Device\n");
+               else if (S_ISFIFO(st.st_ex_mode)) printf("  Fifo\n");
+               else if (S_ISLNK(st.st_ex_mode)) printf("  Symbolic Link\n");
+               else if (S_ISSOCK(st.st_ex_mode)) printf("  Socket\n");
+               printf("  Size: %10u", (unsigned int)st.st_ex_size);
 #ifdef HAVE_STAT_ST_BLOCKS
-               printf(" Blocks: %9u", (unsigned int)st.st_blocks);
+               printf(" Blocks: %9u", (unsigned int)st.st_ex_blocks);
 #endif
 #ifdef HAVE_STAT_ST_BLKSIZE
-               printf(" IO Block: %u\n", (unsigned int)st.st_blksize);
+               printf(" IO Block: %u\n", (unsigned int)st.st_ex_blksize);
 #endif
-               printf("  Device: 0x%10x", (unsigned int)st.st_dev);
-               printf(" Inode: %10u", (unsigned int)st.st_ino);
-               printf(" Links: %10u\n", (unsigned int)st.st_nlink);
-               printf("  Access: %05o", (int)((st.st_mode) & 007777));
+               printf("  Device: 0x%10x", (unsigned int)st.st_ex_dev);
+               printf(" Inode: %10u", (unsigned int)st.st_ex_ino);
+               printf(" Links: %10u\n", (unsigned int)st.st_ex_nlink);
+               printf("  Access: %05o", (int)((st.st_ex_mode) & 007777));
                printf(" Uid: %5lu Gid: %5lu\n",
-                      (unsigned long)st.st_uid,
-                      (unsigned long)st.st_gid);
-               printf("  Access: %s", ctime(&(st.st_atime)));
-               printf("  Modify: %s", ctime(&(st.st_mtime)));
-               printf("  Change: %s", ctime(&(st.st_ctime)));
+                      (unsigned long)st.st_ex_uid,
+                      (unsigned long)st.st_ex_gid);
+               tmp_time = convert_timespec_to_time_t(st.st_ex_atime);
+               printf("  Access: %s", ctime(&tmp_time));
+               tmp_time = convert_timespec_to_time_t(st.st_ex_mtime);
+               printf("  Modify: %s", ctime(&tmp_time));
+               tmp_time = convert_timespec_to_time_t(st.st_ex_ctime);
+               printf("  Change: %s", ctime(&tmp_time));
        }
 
        return NT_STATUS_OK;
@@ -540,6 +544,7 @@ static NTSTATUS cmd_stat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
        struct passwd *pwd = NULL;
        struct group *grp = NULL;
        SMB_STRUCT_STAT st;
+       time_t tmp_time;
 
        if (argc != 2) {
                printf("Usage: stat <fname>\n");
@@ -552,38 +557,41 @@ static NTSTATUS cmd_stat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       pwd = sys_getpwuid(st.st_uid);
+       pwd = sys_getpwuid(st.st_ex_uid);
        if (pwd != NULL) user = pwd->pw_name;
        else user = null_string;
-       grp = sys_getgrgid(st.st_gid);
+       grp = sys_getgrgid(st.st_ex_gid);
        if (grp != NULL) group = grp->gr_name;
        else group = null_string;
 
        printf("stat: ok\n");
        printf("  File: %s", argv[1]);
-       if (S_ISREG(st.st_mode)) printf("  Regular File\n");
-       else if (S_ISDIR(st.st_mode)) printf("  Directory\n");
-       else if (S_ISCHR(st.st_mode)) printf("  Character Device\n");
-       else if (S_ISBLK(st.st_mode)) printf("  Block Device\n");
-       else if (S_ISFIFO(st.st_mode)) printf("  Fifo\n");
-       else if (S_ISLNK(st.st_mode)) printf("  Symbolic Link\n");
-       else if (S_ISSOCK(st.st_mode)) printf("  Socket\n");
-       printf("  Size: %10u", (unsigned int)st.st_size);
+       if (S_ISREG(st.st_ex_mode)) printf("  Regular File\n");
+       else if (S_ISDIR(st.st_ex_mode)) printf("  Directory\n");
+       else if (S_ISCHR(st.st_ex_mode)) printf("  Character Device\n");
+       else if (S_ISBLK(st.st_ex_mode)) printf("  Block Device\n");
+       else if (S_ISFIFO(st.st_ex_mode)) printf("  Fifo\n");
+       else if (S_ISLNK(st.st_ex_mode)) printf("  Symbolic Link\n");
+       else if (S_ISSOCK(st.st_ex_mode)) printf("  Socket\n");
+       printf("  Size: %10u", (unsigned int)st.st_ex_size);
 #ifdef HAVE_STAT_ST_BLOCKS
-       printf(" Blocks: %9u", (unsigned int)st.st_blocks);
+       printf(" Blocks: %9u", (unsigned int)st.st_ex_blocks);
 #endif
 #ifdef HAVE_STAT_ST_BLKSIZE
-       printf(" IO Block: %u\n", (unsigned int)st.st_blksize);
+       printf(" IO Block: %u\n", (unsigned int)st.st_ex_blksize);
 #endif
-       printf("  Device: 0x%10x", (unsigned int)st.st_dev);
-       printf(" Inode: %10u", (unsigned int)st.st_ino);
-       printf(" Links: %10u\n", (unsigned int)st.st_nlink);
-       printf("  Access: %05o", (int)((st.st_mode) & 007777));
-       printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_uid, user, 
-              (unsigned long)st.st_gid, group);
-       printf("  Access: %s", ctime(&(st.st_atime)));
-       printf("  Modify: %s", ctime(&(st.st_mtime)));
-       printf("  Change: %s", ctime(&(st.st_ctime)));
+       printf("  Device: 0x%10x", (unsigned int)st.st_ex_dev);
+       printf(" Inode: %10u", (unsigned int)st.st_ex_ino);
+       printf(" Links: %10u\n", (unsigned int)st.st_ex_nlink);
+       printf("  Access: %05o", (int)((st.st_ex_mode) & 007777));
+       printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_ex_uid, user,
+              (unsigned long)st.st_ex_gid, group);
+       tmp_time = convert_timespec_to_time_t(st.st_ex_atime);
+       printf("  Access: %s", ctime(&tmp_time));
+       tmp_time = convert_timespec_to_time_t(st.st_ex_mtime);
+       printf("  Modify: %s", ctime(&tmp_time));
+       tmp_time = convert_timespec_to_time_t(st.st_ex_ctime);
+       printf("  Change: %s", ctime(&tmp_time));
 
        return NT_STATUS_OK;
 }
@@ -597,6 +605,7 @@ static NTSTATUS cmd_fstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
        struct passwd *pwd = NULL;
        struct group *grp = NULL;
        SMB_STRUCT_STAT st;
+       time_t tmp_time;
 
        if (argc != 2) {
                printf("Usage: fstat <fd>\n");
@@ -619,37 +628,40 @@ static NTSTATUS cmd_fstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       pwd = sys_getpwuid(st.st_uid);
+       pwd = sys_getpwuid(st.st_ex_uid);
        if (pwd != NULL) user = pwd->pw_name;
        else user = null_string;
-       grp = sys_getgrgid(st.st_gid);
+       grp = sys_getgrgid(st.st_ex_gid);
        if (grp != NULL) group = grp->gr_name;
        else group = null_string;
 
        printf("fstat: ok\n");
-       if (S_ISREG(st.st_mode)) printf("  Regular File\n");
-       else if (S_ISDIR(st.st_mode)) printf("  Directory\n");
-       else if (S_ISCHR(st.st_mode)) printf("  Character Device\n");
-       else if (S_ISBLK(st.st_mode)) printf("  Block Device\n");
-       else if (S_ISFIFO(st.st_mode)) printf("  Fifo\n");
-       else if (S_ISLNK(st.st_mode)) printf("  Symbolic Link\n");
-       else if (S_ISSOCK(st.st_mode)) printf("  Socket\n");
-       printf("  Size: %10u", (unsigned int)st.st_size);
+       if (S_ISREG(st.st_ex_mode)) printf("  Regular File\n");
+       else if (S_ISDIR(st.st_ex_mode)) printf("  Directory\n");
+       else if (S_ISCHR(st.st_ex_mode)) printf("  Character Device\n");
+       else if (S_ISBLK(st.st_ex_mode)) printf("  Block Device\n");
+       else if (S_ISFIFO(st.st_ex_mode)) printf("  Fifo\n");
+       else if (S_ISLNK(st.st_ex_mode)) printf("  Symbolic Link\n");
+       else if (S_ISSOCK(st.st_ex_mode)) printf("  Socket\n");
+       printf("  Size: %10u", (unsigned int)st.st_ex_size);
 #ifdef HAVE_STAT_ST_BLOCKS
-       printf(" Blocks: %9u", (unsigned int)st.st_blocks);
+       printf(" Blocks: %9u", (unsigned int)st.st_ex_blocks);
 #endif
 #ifdef HAVE_STAT_ST_BLKSIZE
-       printf(" IO Block: %u\n", (unsigned int)st.st_blksize);
+       printf(" IO Block: %u\n", (unsigned int)st.st_ex_blksize);
 #endif
-       printf("  Device: 0x%10x", (unsigned int)st.st_dev);
-       printf(" Inode: %10u", (unsigned int)st.st_ino);
-       printf(" Links: %10u\n", (unsigned int)st.st_nlink);
-       printf("  Access: %05o", (int)((st.st_mode) & 007777));
-       printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_uid, user, 
-              (unsigned long)st.st_gid, group);
-       printf("  Access: %s", ctime(&(st.st_atime)));
-       printf("  Modify: %s", ctime(&(st.st_mtime)));
-       printf("  Change: %s", ctime(&(st.st_ctime)));
+       printf("  Device: 0x%10x", (unsigned int)st.st_ex_dev);
+       printf(" Inode: %10u", (unsigned int)st.st_ex_ino);
+       printf(" Links: %10u\n", (unsigned int)st.st_ex_nlink);
+       printf("  Access: %05o", (int)((st.st_ex_mode) & 007777));
+       printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_ex_uid, user,
+              (unsigned long)st.st_ex_gid, group);
+       tmp_time = convert_timespec_to_time_t(st.st_ex_atime);
+       printf("  Access: %s", ctime(&tmp_time));
+       tmp_time = convert_timespec_to_time_t(st.st_ex_mtime);
+       printf("  Modify: %s", ctime(&tmp_time));
+       tmp_time = convert_timespec_to_time_t(st.st_ex_ctime);
+       printf("  Change: %s", ctime(&tmp_time));
 
        return NT_STATUS_OK;
 }
@@ -662,6 +674,7 @@ static NTSTATUS cmd_lstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
        struct passwd *pwd = NULL;
        struct group *grp = NULL;
        SMB_STRUCT_STAT st;
+       time_t tmp_time;
 
        if (argc != 2) {
                printf("Usage: lstat <path>\n");
@@ -673,37 +686,40 @@ static NTSTATUS cmd_lstat(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       pwd = sys_getpwuid(st.st_uid);
+       pwd = sys_getpwuid(st.st_ex_uid);
        if (pwd != NULL) user = pwd->pw_name;
        else user = null_string;
-       grp = sys_getgrgid(st.st_gid);
+       grp = sys_getgrgid(st.st_ex_gid);
        if (grp != NULL) group = grp->gr_name;
        else group = null_string;
 
        printf("lstat: ok\n");
-       if (S_ISREG(st.st_mode)) printf("  Regular File\n");
-       else if (S_ISDIR(st.st_mode)) printf("  Directory\n");
-       else if (S_ISCHR(st.st_mode)) printf("  Character Device\n");
-       else if (S_ISBLK(st.st_mode)) printf("  Block Device\n");
-       else if (S_ISFIFO(st.st_mode)) printf("  Fifo\n");
-       else if (S_ISLNK(st.st_mode)) printf("  Symbolic Link\n");
-       else if (S_ISSOCK(st.st_mode)) printf("  Socket\n");
-       printf("  Size: %10u", (unsigned int)st.st_size);
+       if (S_ISREG(st.st_ex_mode)) printf("  Regular File\n");
+       else if (S_ISDIR(st.st_ex_mode)) printf("  Directory\n");
+       else if (S_ISCHR(st.st_ex_mode)) printf("  Character Device\n");
+       else if (S_ISBLK(st.st_ex_mode)) printf("  Block Device\n");
+       else if (S_ISFIFO(st.st_ex_mode)) printf("  Fifo\n");
+       else if (S_ISLNK(st.st_ex_mode)) printf("  Symbolic Link\n");
+       else if (S_ISSOCK(st.st_ex_mode)) printf("  Socket\n");
+       printf("  Size: %10u", (unsigned int)st.st_ex_size);
 #ifdef HAVE_STAT_ST_BLOCKS
-       printf(" Blocks: %9u", (unsigned int)st.st_blocks);
+       printf(" Blocks: %9u", (unsigned int)st.st_ex_blocks);
 #endif
 #ifdef HAVE_STAT_ST_BLKSIZE
-       printf(" IO Block: %u\n", (unsigned int)st.st_blksize);
+       printf(" IO Block: %u\n", (unsigned int)st.st_ex_blksize);
 #endif
-       printf("  Device: 0x%10x", (unsigned int)st.st_dev);
-       printf(" Inode: %10u", (unsigned int)st.st_ino);
-       printf(" Links: %10u\n", (unsigned int)st.st_nlink);
-       printf("  Access: %05o", (int)((st.st_mode) & 007777));
-       printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_uid, user, 
-              (unsigned long)st.st_gid, group);
-       printf("  Access: %s", ctime(&(st.st_atime)));
-       printf("  Modify: %s", ctime(&(st.st_mtime)));
-       printf("  Change: %s", ctime(&(st.st_ctime)));
+       printf("  Device: 0x%10x", (unsigned int)st.st_ex_dev);
+       printf(" Inode: %10u", (unsigned int)st.st_ex_ino);
+       printf(" Links: %10u\n", (unsigned int)st.st_ex_nlink);
+       printf("  Access: %05o", (int)((st.st_ex_mode) & 007777));
+       printf(" Uid: %5lu/%.16s Gid: %5lu/%.16s\n", (unsigned long)st.st_ex_uid, user,
+              (unsigned long)st.st_ex_gid, group);
+       tmp_time = convert_timespec_to_time_t(st.st_ex_atime);
+       printf("  Access: %s", ctime(&tmp_time));
+       tmp_time = convert_timespec_to_time_t(st.st_ex_mtime);
+       printf("  Modify: %s", ctime(&tmp_time));
+       tmp_time = convert_timespec_to_time_t(st.st_ex_ctime);
+       printf("  Change: %s", ctime(&tmp_time));
        
        return NT_STATUS_OK;
 }
index 1dd8c1fc10264c20aa516d7f2b6caabb3c16562e..ca3cb0bfda1fb9a98b18e3098e86035f0b6c5aa6 100644 (file)
@@ -662,7 +662,7 @@ static int net_conf_addshare(struct net_context *c,
                goto done;
        }
 
-       if (!S_ISDIR(sbuf.st_mode)) {
+       if (!S_ISDIR(sbuf.st_ex_mode)) {
                d_fprintf(stderr,
                          "ERROR: path '%s' is not a directory.\n",
                          path);
index 314f9167a5dd93280bce23879635bdd7dd0bc0c6..9dd1560b2e64cee99ee587e64a6368b19183134e 100644 (file)
@@ -250,13 +250,13 @@ static int get_share_list(TALLOC_CTX *ctx, const char *wcard, bool only_ours)
                        continue;
                }
 
-               if (!S_ISREG(sbuf.st_mode)) {
+               if (!S_ISREG(sbuf.st_ex_mode)) {
                        d_fprintf(stderr, "get_share_list: file %s is not a regular file. Ignoring.\n",
                                path );
                        continue;
                }
 
-               if (only_ours && sbuf.st_uid != myuid) {
+               if (only_ours && sbuf.st_ex_uid != myuid) {
                        continue;
                }
 
@@ -364,7 +364,7 @@ static int info_fn(struct file_list *fl, void *priv)
                return -1;
        }
 
-       if (!S_ISREG(sbuf.st_mode)) {
+       if (!S_ISREG(sbuf.st_ex_mode)) {
                d_fprintf(stderr, "info_fn: file %s is not a regular file. Ignoring.\n",
                        basepath );
                close(fd);
@@ -574,7 +574,7 @@ static int count_num_usershares(void)
                        continue;
                }
 
-               if (!S_ISREG(sbuf.st_mode)) {
+               if (!S_ISREG(sbuf.st_ex_mode)) {
                        d_fprintf(stderr, "count_num_usershares: file %s is not a regular file. Ignoring.\n",
                                path );
                        continue;
@@ -738,7 +738,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
                return -1;
        }
 
-       if (!S_ISDIR(sbuf.st_mode)) {
+       if (!S_ISDIR(sbuf.st_ex_mode)) {
                d_fprintf(stderr, "net usershare add: path %s is not a directory.\n",
                        us_path );
                TALLOC_FREE(ctx);
@@ -749,7 +749,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
        /* If we're not root, check if we're restricted to sharing out directories
           that we own only. */
 
-       if ((myeuid != 0) && lp_usershare_owner_only() && (myeuid != sbuf.st_uid)) {
+       if ((myeuid != 0) && lp_usershare_owner_only() && (myeuid != sbuf.st_ex_uid)) {
                d_fprintf(stderr, "net usershare add: cannot share path %s as "
                        "we are restricted to only sharing directories we own.\n"
                        "\tAsk the administrator to add the line \"usershare owner only = false\" \n"
@@ -887,7 +887,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
                return -1;
        }
 
-       if (!S_ISREG(sbuf.st_mode) || sbuf.st_dev != lsbuf.st_dev || sbuf.st_ino != lsbuf.st_ino) {
+       if (!S_ISREG(sbuf.st_ex_mode) || sbuf.st_ex_dev != lsbuf.st_ex_dev || sbuf.st_ex_ino != lsbuf.st_ex_ino) {
                d_fprintf(stderr, "net usershare add: tmp file %s is not a regular file ?\n",
                                full_path_tmp );
                TALLOC_FREE(ctx);
index e8458fda1b6c7b74d3d51593f00c72552a6b9850..519eb6954a7a38217ef4b72bb0c3a599125f33fe 100644 (file)
@@ -60,7 +60,7 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
                fprintf(stderr, "ERROR: lock directory %s does not exist\n",
                       lp_lockdir());
                ret = 1;
-       } else if ((st.st_mode & 0777) != 0755) {
+       } else if ((st.st_ex_mode & 0777) != 0755) {
                fprintf(stderr, "WARNING: lock directory %s should have permissions 0755 for browsing to work\n",
                       lp_lockdir());
                ret = 1;
@@ -70,7 +70,7 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
                fprintf(stderr, "ERROR: state directory %s does not exist\n",
                       lp_statedir());
                ret = 1;
-       } else if ((st.st_mode & 0777) != 0755) {
+       } else if ((st.st_ex_mode & 0777) != 0755) {
                fprintf(stderr, "WARNING: state directory %s should have permissions 0755 for browsing to work\n",
                       lp_statedir());
                ret = 1;
@@ -80,7 +80,7 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
                fprintf(stderr, "ERROR: cache directory %s does not exist\n",
                       lp_cachedir());
                ret = 1;
-       } else if ((st.st_mode & 0777) != 0755) {
+       } else if ((st.st_ex_mode & 0777) != 0755) {
                fprintf(stderr, "WARNING: cache directory %s should have permissions 0755 for browsing to work\n",
                       lp_cachedir());
                ret = 1;
index dd0aadb78680a4d7ad2aa0ce42757591a9908b23..6cf3fe6aafba32246be2d7a6bcad41276168b035 100644 (file)
@@ -448,16 +448,16 @@ static void cgi_download(char *file)
                                "The requested file was not found");
        }
 
-       if (S_ISDIR(st.st_mode))
+       if (S_ISDIR(st.st_ex_mode))
        {
                snprintf(buf, sizeof(buf), "%s/index.html", file);
-               if (!file_exist_stat(buf, &st) || !S_ISREG(st.st_mode))
+               if (!file_exist_stat(buf, &st) || !S_ISREG(st.st_ex_mode))
                {
                        cgi_setup_error("404 File Not Found","",
                                        "The requested file was not found");
                }
        }
-       else if (S_ISREG(st.st_mode))
+       else if (S_ISREG(st.st_ex_mode))
        {
                snprintf(buf, sizeof(buf), "%s", file);
        }
@@ -496,7 +496,7 @@ static void cgi_download(char *file)
                printf("Content-Language: %s\r\n", lang);
        }
 
-       printf("Content-Length: %d\r\n\r\n", (int)st.st_size);
+       printf("Content-Length: %d\r\n\r\n", (int)st.st_ex_size);
        while ((l=read(fd,buf,sizeof(buf)))>0) {
                if (fwrite(buf, 1, l, stdout) != l) {
                        break;