Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jan 2016 11:51:41 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r294264 - stable/9/sys/fs/smbfs
Message-ID:  <201601181151.u0IBpfYp036140@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Mon Jan 18 11:51:41 2016
New Revision: 294264
URL: https://svnweb.freebsd.org/changeset/base/294264

Log:
  MFC r293679:
    Change the type of newsize argument in the smbfs_smb_setfsize() function
    from int to int64.
    MSDN says that SMB_SET_FILE_END_OF_FILE_INFO uses signed 64-bit integer
    to specify offset, but since smbfs_smb_setfsize() has used plain int,
    a value was truncated in case when offset was larger than 2G.
    	https://msdn.microsoft.com/en-us/library/ff469975.aspx
  
    In particular, now `truncate -s 10G` will work correctly on the mounted
    SMB share.

Modified:
  stable/9/sys/fs/smbfs/smbfs_smb.c
  stable/9/sys/fs/smbfs/smbfs_subr.h
  stable/9/sys/fs/smbfs/smbfs_vnops.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/smbfs/smbfs_smb.c
==============================================================================
--- stable/9/sys/fs/smbfs/smbfs_smb.c	Mon Jan 18 11:47:03 2016	(r294263)
+++ stable/9/sys/fs/smbfs/smbfs_smb.c	Mon Jan 18 11:51:41 2016	(r294264)
@@ -331,18 +331,18 @@ smbfs_smb_flush(struct smbnode *np, stru
 }
 
 int
-smbfs_smb_setfsize(struct smbnode *np, int newsize, struct smb_cred *scred)
+smbfs_smb_setfsize(struct smbnode *np, int64_t newsize, struct smb_cred *scred)
 {
 	struct smb_share *ssp = np->n_mount->sm_share;
 	struct smb_rq rq, *rqp = &rq;
 	struct mbchain *mbp;
 	int error;
 
-	if (!smbfs_smb_seteof(np, (int64_t) newsize, scred)) {
+	if (!smbfs_smb_seteof(np, newsize, scred)) {
 		np->n_flag |= NFLUSHWIRE;
 		return (0);
 	}
-
+	/* XXX: We should use SMB_COM_WRITE_ANDX to support large offsets */
 	error = smb_rq_init(rqp, SSTOCP(ssp), SMB_COM_WRITE, scred);
 	if (error)
 		return error;
@@ -350,7 +350,7 @@ smbfs_smb_setfsize(struct smbnode *np, i
 	smb_rq_wstart(rqp);
 	mb_put_mem(mbp, (caddr_t)&np->n_fid, 2, MB_MSYSTEM);
 	mb_put_uint16le(mbp, 0);
-	mb_put_uint32le(mbp, newsize);
+	mb_put_uint32le(mbp, (uint32_t)newsize);
 	mb_put_uint16le(mbp, 0);
 	smb_rq_wend(rqp);
 	smb_rq_bstart(rqp);

Modified: stable/9/sys/fs/smbfs/smbfs_subr.h
==============================================================================
--- stable/9/sys/fs/smbfs/smbfs_subr.h	Mon Jan 18 11:47:03 2016	(r294263)
+++ stable/9/sys/fs/smbfs/smbfs_subr.h	Mon Jan 18 11:51:41 2016	(r294264)
@@ -127,7 +127,8 @@ int  smbfs_smb_lock(struct smbnode *np, 
 	off_t start, off_t end,	struct smb_cred *scred);
 int  smbfs_smb_statfs(struct smb_share *ssp, struct statfs *sbp,
 	struct smb_cred *scred);
-int  smbfs_smb_setfsize(struct smbnode *np, int newsize, struct smb_cred *scred);
+int  smbfs_smb_setfsize(struct smbnode *np, int64_t newsize,
+	struct smb_cred *scred);
 
 int  smbfs_smb_query_info(struct smbnode *np, const char *name, int len,
 	struct smbfattr *fap, struct smb_cred *scred);

Modified: stable/9/sys/fs/smbfs/smbfs_vnops.c
==============================================================================
--- stable/9/sys/fs/smbfs/smbfs_vnops.c	Mon Jan 18 11:47:03 2016	(r294263)
+++ stable/9/sys/fs/smbfs/smbfs_vnops.c	Mon Jan 18 11:51:41 2016	(r294264)
@@ -332,7 +332,8 @@ smbfs_setattr(ap)
 				doclose = 1;
 		}
 		if (error == 0)
-			error = smbfs_smb_setfsize(np, vap->va_size, &scred);
+			error = smbfs_smb_setfsize(np,
+			    (int64_t)vap->va_size, &scred);
 		if (doclose)
 			smbfs_smb_close(ssp, np->n_fid, NULL, &scred);
 		if (error) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601181151.u0IBpfYp036140>