Module Name: src Committed By: bouyer Date: Tue Oct 27 20:46:53 UTC 2009
Modified Files: src/sys/fs/smbfs [netbsd-5]: smbfs_smb.c smbfs_subr.h Log Message: Pull up following revision(s) (requested by tron in ticket #1109): sys/fs/smbfs/smbfs_smb.c: revision 1.41 sys/fs/smbfs/smbfs_subr.h: revision 1.20 Add support for 64 bit file offsets to smbfs_smb_setfsize(), largely based on code taken from FreeBSD. This stops truncation of files larger than 4GB by VOP_SETATTR() which e.g. happened when copying large files "rump_smbfs". Kudos to Antti Kantee for diagnosing the problem in smbfs_smb_setfsize(). To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.37.6.1 src/sys/fs/smbfs/smbfs_smb.c cvs rdiff -u -r1.19 -r1.19.6.1 src/sys/fs/smbfs/smbfs_subr.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.37 src/sys/fs/smbfs/smbfs_smb.c:1.37.6.1 --- src/sys/fs/smbfs/smbfs_smb.c:1.37 Tue Jun 24 10:23:48 2008 +++ src/sys/fs/smbfs/smbfs_smb.c Tue Oct 27 20:46:52 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: smbfs_smb.c,v 1.37 2008/06/24 10:23:48 gmcgarry Exp $ */ +/* $NetBSD: smbfs_smb.c,v 1.37.6.1 2009/10/27 20:46:52 bouyer 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.37 2008/06/24 10:23:48 gmcgarry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: smbfs_smb.c,v 1.37.6.1 2009/10/27 20:46:52 bouyer Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -265,14 +265,50 @@ return 0; } +static int +smbfs_smb_seteof(struct smbnode *np, int64_t newsize, struct smb_cred *scred) +{ + struct smb_t2rq *t2p; + struct smb_share *ssp = np->n_mount->sm_share; + struct mbchain *mbp; + int error; + + error = smb_t2_alloc(SSTOCP(ssp), SMB_TRANS2_SET_FILE_INFORMATION, + scred, &t2p); + if (error) + return error; + mbp = &t2p->t2_tparam; + mb_init(mbp); + mb_put_mem(mbp, (void *)&np->n_fid, 2, MB_MSYSTEM); + mb_put_uint16le(mbp, SMB_SET_FILE_END_OF_FILE_INFO); + mb_put_uint32le(mbp, 0); + mbp = &t2p->t2_tdata; + mb_init(mbp); + mb_put_int64le(mbp, newsize); + mb_put_uint32le(mbp, 0); /* padding */ + mb_put_uint16le(mbp, 0); + t2p->t2_maxpcount = 2; + t2p->t2_maxdcount = 0; + error = smb_t2_request(t2p); + smb_t2_done(t2p); + return error; +} + int -smbfs_smb_setfsize(struct smbnode *np, int newsize, struct smb_cred *scred) +smbfs_smb_setfsize(struct smbnode *np, u_quad_t newsize, + struct smb_cred *scred) { struct smb_share *ssp = np->n_mount->sm_share; struct smb_rq *rqp; struct mbchain *mbp; int error; + if (newsize >= (1LL << 32)) { + if (!(SMB_CAPS(SSTOVC(ssp)) & SMB_CAP_LARGE_FILES)) + return EFBIG; + return smbfs_smb_seteof(np, (int64_t)newsize, scred); + } + error = smb_rq_alloc(SSTOCP(ssp), SMB_COM_WRITE, scred, &rqp); if (error) return error; Index: src/sys/fs/smbfs/smbfs_subr.h diff -u src/sys/fs/smbfs/smbfs_subr.h:1.19 src/sys/fs/smbfs/smbfs_subr.h:1.19.6.1 --- src/sys/fs/smbfs/smbfs_subr.h:1.19 Sat Jun 28 01:34:05 2008 +++ src/sys/fs/smbfs/smbfs_subr.h Tue Oct 27 20:46:52 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: smbfs_subr.h,v 1.19 2008/06/28 01:34:05 rumble Exp $ */ +/* $NetBSD: smbfs_subr.h,v 1.19.6.1 2009/10/27 20:46:52 bouyer Exp $ */ /* * Copyright (c) 2000-2001, Boris Popov @@ -135,7 +135,8 @@ off_t start, off_t end, struct smb_cred *scred); int smbfs_smb_statvfs(struct smb_share *ssp, struct statvfs *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, u_quad_t newsize, + struct smb_cred *scred); int smbfs_smb_setpattr(struct smbnode *np, u_int16_t attr, struct timespec *mtime, struct smb_cred *scred);