Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Improve smbfs timestamp handling.



details:   https://anonhg.NetBSD.org/src/rev/be55fcfaae28
branches:  trunk
changeset: 782996:be55fcfaae28
user:      nakayama <nakayama%NetBSD.org@localhost>
date:      Fri Nov 30 23:24:21 2012 +0000

description:
Improve smbfs timestamp handling.
Don't round timestamp to 2 seconds resolution if the server
supports the CAP_INFOLEVEL_PASSTHRU capability.

diffstat:

 sys/fs/smbfs/smbfs_smb.c   |  27 +++++++++++++++++----------
 sys/fs/smbfs/smbfs_subr.c  |   6 +++---
 sys/fs/smbfs/smbfs_subr.h  |   4 +---
 sys/fs/smbfs/smbfs_vnops.c |   7 +++----
 sys/netsmb/smb.h           |   3 ++-
 5 files changed, 26 insertions(+), 21 deletions(-)

diffs (171 lines):

diff -r 6a0d68e7642a -r be55fcfaae28 sys/fs/smbfs/smbfs_smb.c
--- a/sys/fs/smbfs/smbfs_smb.c  Fri Nov 30 18:13:30 2012 +0000
+++ b/sys/fs/smbfs/smbfs_smb.c  Fri Nov 30 23:24:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smbfs_smb.c,v 1.43 2012/11/24 19:48:24 nakayama Exp $  */
+/*     $NetBSD: smbfs_smb.c,v 1.44 2012/11/30 23:24:21 nakayama Exp $  */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smbfs_smb.c,v 1.43 2012/11/24 19:48:24 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smbfs_smb.c,v 1.44 2012/11/30 23:24:21 nakayama Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -430,7 +430,6 @@
 /*
  * NT level. Specially for win9x
  */
-#if 0
 int
 smbfs_smb_setpattrNT(struct smbnode *np, u_short attr, struct timespec *mtime,
        struct timespec *atime, struct smb_cred *scred)
@@ -442,13 +441,22 @@
        int64_t tm;
        int error, tzoff;
 
+       /*
+        * SMB_SET_FILE_BASIC_INFO isn't supported for
+        * SMB_TRANS2_SET_PATH_INFORMATION,
+        * so use SMB_SET_FILE_BASIC_INFORMATION instead,
+        * but it requires SMB_CAP_INFOLEVEL_PASSTHRU capability.
+        */
+       if ((SMB_CAPS(vcp) & SMB_CAP_INFOLEVEL_PASSTHRU) == 0)
+               return smbfs_smb_setptime2(np, mtime, atime, attr, scred);
+
        error = smb_t2_alloc(SSTOCP(ssp), SMB_TRANS2_SET_PATH_INFORMATION,
            scred, &t2p);
        if (error)
                return error;
        mbp = &t2p->t2_tparam;
        mb_init(mbp);
-       mb_put_uint16le(mbp, SMB_SET_FILE_BASIC_INFO);
+       mb_put_uint16le(mbp, SMB_SET_FILE_BASIC_INFORMATION);
        mb_put_uint32le(mbp, 0);                /* MBZ */
        error = smbfs_fullpath(mbp, vcp, np, NULL, 0);
        if (error) {
@@ -471,13 +479,13 @@
        mb_put_int64le(mbp, tm);
        mb_put_int64le(mbp, tm);                /* change time */
        mb_put_uint32le(mbp, attr);             /* attr */
-       t2p->t2_maxpcount = 24;
-       t2p->t2_maxdcount = 56;
+       mb_put_uint32le(mbp, 0);                /* padding */
+       t2p->t2_maxpcount = 2;
+       t2p->t2_maxdcount = 0;
        error = smb_t2_request(t2p);
        smb_t2_done(t2p);
        return error;
 }
-#endif
 
 /*
  * Set file atime and mtime. Doesn't supported by core dialect.
@@ -560,9 +568,8 @@
                tm = 0;
        mb_put_int64le(mbp, tm);
        mb_put_int64le(mbp, tm);                /* change time */
-       mb_put_uint16le(mbp, attr);
-       mb_put_uint32le(mbp, 0);                        /* padding */
-       mb_put_uint16le(mbp, 0);
+       mb_put_uint32le(mbp, attr);             /* attr */
+       mb_put_uint32le(mbp, 0);                /* padding */
        t2p->t2_maxpcount = 2;
        t2p->t2_maxdcount = 0;
        error = smb_t2_request(t2p);
diff -r 6a0d68e7642a -r be55fcfaae28 sys/fs/smbfs/smbfs_subr.c
--- a/sys/fs/smbfs/smbfs_subr.c Fri Nov 30 18:13:30 2012 +0000
+++ b/sys/fs/smbfs/smbfs_subr.c Fri Nov 30 23:24:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smbfs_subr.c,v 1.15 2011/06/09 02:59:22 rmind Exp $    */
+/*     $NetBSD: smbfs_subr.c,v 1.16 2012/11/30 23:24:21 nakayama Exp $ */
 
 /*
  * Copyright (c) 2000-2001, Boris Popov
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smbfs_subr.c,v 1.15 2011/06/09 02:59:22 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smbfs_subr.c,v 1.16 2012/11/30 23:24:21 nakayama Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -145,7 +145,7 @@
        u_long seconds;
 
        smb_time_local2server(tsp, 0, &seconds);
-       *nsec = (((int64_t)(seconds) & ~1) + DIFF1970TO1601) * (int64_t)10000000;
+       *nsec = ((int64_t)seconds + DIFF1970TO1601) * (int64_t)10000000;
 }
 
 void
diff -r 6a0d68e7642a -r be55fcfaae28 sys/fs/smbfs/smbfs_subr.h
--- a/sys/fs/smbfs/smbfs_subr.h Fri Nov 30 18:13:30 2012 +0000
+++ b/sys/fs/smbfs/smbfs_subr.h Fri Nov 30 23:24:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smbfs_subr.h,v 1.20 2009/10/20 20:55:01 tron Exp $     */
+/*     $NetBSD: smbfs_subr.h,v 1.21 2012/11/30 23:24:21 nakayama Exp $ */
 
 /*
  * Copyright (c) 2000-2001, Boris Popov
@@ -142,10 +142,8 @@
        struct timespec *mtime, struct smb_cred *scred);
 int  smbfs_smb_setptime2(struct smbnode *np, struct timespec *mtime,
        struct timespec *atime, int attr, struct smb_cred *scred);
-#if 0
 int  smbfs_smb_setpattrNT(struct smbnode *np, u_int16_t attr,
        struct timespec *mtime, struct timespec *atime, struct smb_cred *scred);
-#endif
 
 int  smbfs_smb_setftime(struct smbnode *np, struct timespec *mtime,
        struct timespec *atime, struct smb_cred *scred);
diff -r 6a0d68e7642a -r be55fcfaae28 sys/fs/smbfs/smbfs_vnops.c
--- a/sys/fs/smbfs/smbfs_vnops.c        Fri Nov 30 18:13:30 2012 +0000
+++ b/sys/fs/smbfs/smbfs_vnops.c        Fri Nov 30 23:24:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smbfs_vnops.c,v 1.84 2012/11/29 11:58:49 nakayama Exp $        */
+/*     $NetBSD: smbfs_vnops.c,v 1.85 2012/11/30 23:24:21 nakayama Exp $        */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smbfs_vnops.c,v 1.84 2012/11/29 11:58:49 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smbfs_vnops.c,v 1.85 2012/11/30 23:24:21 nakayama Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -497,8 +497,7 @@
                                VOP_CLOSE(vp, FWRITE, ap->a_cred);
                                }
                        } else if (SMB_CAPS(vcp) & SMB_CAP_NT_SMBS) {
-                               error = smbfs_smb_setptime2(np, mtime, atime, 0, &scred);
-/*                             error = smbfs_smb_setpattrNT(np, 0, mtime, atime, &scred);*/
+                               error = smbfs_smb_setpattrNT(np, 0, mtime, atime, &scred);
                        } else if (SMB_DIALECT(vcp) >= SMB_DIALECT_LANMAN2_0) {
                                error = smbfs_smb_setptime2(np, mtime, atime, 0, &scred);
                        } else {
diff -r 6a0d68e7642a -r be55fcfaae28 sys/netsmb/smb.h
--- a/sys/netsmb/smb.h  Fri Nov 30 18:13:30 2012 +0000
+++ b/sys/netsmb/smb.h  Fri Nov 30 23:24:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smb.h,v 1.19 2011/09/27 02:05:10 christos Exp $        */
+/*     $NetBSD: smb.h,v 1.20 2012/11/30 23:24:22 nakayama Exp $        */
 
 /*
  * Copyright (c) 2000-2001 Boris Popov
@@ -374,6 +374,7 @@
  */
 #define        SMB_SET_FILE_BASIC_INFO         0x101
 #define        SMB_SET_FILE_END_OF_FILE_INFO   0x104
+#define        SMB_SET_FILE_BASIC_INFORMATION  1004
 
 /*
  * LOCKING_ANDX LockType flags



Home | Main Index | Thread Index | Old Index