Module Name:    src
Committed By:   nakayama
Date:           Fri Nov 30 23:24:22 UTC 2012

Modified Files:
        src/sys/fs/smbfs: smbfs_smb.c smbfs_subr.c smbfs_subr.h smbfs_vnops.c
        src/sys/netsmb: smb.h

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


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/fs/smbfs/smbfs_smb.c
cvs rdiff -u -r1.15 -r1.16 src/sys/fs/smbfs/smbfs_subr.c
cvs rdiff -u -r1.20 -r1.21 src/sys/fs/smbfs/smbfs_subr.h
cvs rdiff -u -r1.84 -r1.85 src/sys/fs/smbfs/smbfs_vnops.c
cvs rdiff -u -r1.19 -r1.20 src/sys/netsmb/smb.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/smbfs/smbfs_smb.c
diff -u src/sys/fs/smbfs/smbfs_smb.c:1.43 src/sys/fs/smbfs/smbfs_smb.c:1.44
--- src/sys/fs/smbfs/smbfs_smb.c:1.43	Sat Nov 24 19:48:24 2012
+++ src/sys/fs/smbfs/smbfs_smb.c	Fri Nov 30 23:24:21 2012
@@ -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 @@ smbfs_smb_setptime2(struct smbnode *np, 
 /*
  * 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 @@ smbfs_smb_setpattrNT(struct smbnode *np,
 	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 @@ smbfs_smb_setpattrNT(struct smbnode *np,
 	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 @@ smbfs_smb_setfattrNT(struct smbnode *np,
 		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);

Index: src/sys/fs/smbfs/smbfs_subr.c
diff -u src/sys/fs/smbfs/smbfs_subr.c:1.15 src/sys/fs/smbfs/smbfs_subr.c:1.16
--- src/sys/fs/smbfs/smbfs_subr.c:1.15	Thu Jun  9 02:59:22 2011
+++ src/sys/fs/smbfs/smbfs_subr.c	Fri Nov 30 23:24:21 2012
@@ -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 @@ smb_time_local2NT(struct timespec *tsp, 
 	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

Index: src/sys/fs/smbfs/smbfs_subr.h
diff -u src/sys/fs/smbfs/smbfs_subr.h:1.20 src/sys/fs/smbfs/smbfs_subr.h:1.21
--- src/sys/fs/smbfs/smbfs_subr.h:1.20	Tue Oct 20 20:55:01 2009
+++ src/sys/fs/smbfs/smbfs_subr.h	Fri Nov 30 23:24:21 2012
@@ -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 @@ int  smbfs_smb_setpattr(struct smbnode *
 	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);

Index: src/sys/fs/smbfs/smbfs_vnops.c
diff -u src/sys/fs/smbfs/smbfs_vnops.c:1.84 src/sys/fs/smbfs/smbfs_vnops.c:1.85
--- src/sys/fs/smbfs/smbfs_vnops.c:1.84	Thu Nov 29 11:58:49 2012
+++ src/sys/fs/smbfs/smbfs_vnops.c	Fri Nov 30 23:24:21 2012
@@ -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 @@ smbfs_setattr(void *v)
 				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 {

Index: src/sys/netsmb/smb.h
diff -u src/sys/netsmb/smb.h:1.19 src/sys/netsmb/smb.h:1.20
--- src/sys/netsmb/smb.h:1.19	Tue Sep 27 02:05:10 2011
+++ src/sys/netsmb/smb.h	Fri Nov 30 23:24:22 2012
@@ -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 @@ enum smb_dialects {
  */
 #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

Reply via email to