Date: Wed, 31 Aug 2005 21:10:25 GMT From: dad@netroad.ru To: freebsd-bugs@FreeBSD.org Subject: Re: kern/42652: [smbfs] error deleting r/o (by windows) files on smbfs Message-ID: <200508312110.j7VLAPOu003762@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/42652; it has been noted by GNATS. From: dad@netroad.ru To: bug-followup@FreeBSD.org, raven@bingo.chel.ru Cc: Subject: Re: kern/42652: [smbfs] error deleting r/o (by windows) files on smbfs Date: Thu, 1 Sep 2005 01:07:44 +0400 --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I have faced this problem myself and implemented a real fix for it. Attached are patches for RELENG_4, RELENG_5 and RELENG_6 branches. They apply cleanly as well to RELENG_4_11 and RELENG_5_4 branches. The patch for RELENG_6 also fits for the HEAD branch. I am personally using patched kernels on 4.11-RELEASE-p9 and 5.4-RELEASE-p1 for a couple of weeks already without any problems enjoying the functionality. Though, I must admit, I have not tested the patch neither on -6 nor -HEAD, but nevetherless I think it's rather staightforward and must work as expected. I think it would be nice to get this commited. --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="smbfs_4.patch" diff -ruN RELENG_4/usr/src-orig/sys/fs/smbfs/smbfs_node.c RELENG_4/usr/src/sys/fs/smbfs/smbfs_node.c --- RELENG_4/usr/src-orig/sys/fs/smbfs/smbfs_node.c Wed Aug 31 11:24:29 2005 +++ RELENG_4/usr/src/sys/fs/smbfs/smbfs_node.c Wed Aug 31 11:27:31 2005 @@ -45,6 +45,7 @@ /*#include <vm/vm_page.h> #include <vm/vm_object.h>*/ #include <sys/queue.h> +#include <sys/stat.h> #include <netsmb/smb.h> #include <netsmb/smb_conn.h> @@ -415,6 +416,8 @@ va->va_type = vp->v_type; /* vnode type (for create) */ if (vp->v_type == VREG) { va->va_mode = smp->sm_args.file_mode; /* files access mode and type */ + if (np->n_dosattr & SMB_FA_RDONLY) + va->va_mode &= ~(S_IWUSR|S_IWGRP|S_IWOTH); } else if (vp->v_type == VDIR) { va->va_mode = smp->sm_args.dir_mode; /* files access mode and type */ } else diff -ruN RELENG_4/usr/src-orig/sys/fs/smbfs/smbfs_smb.c RELENG_4/usr/src/sys/fs/smbfs/smbfs_smb.c --- RELENG_4/usr/src-orig/sys/fs/smbfs/smbfs_smb.c Wed Aug 31 11:24:29 2005 +++ RELENG_4/usr/src/sys/fs/smbfs/smbfs_smb.c Wed Aug 31 11:27:32 2005 @@ -512,9 +512,10 @@ mb_put_uint8(mbp, 0); smb_rq_bend(rqp); error = smb_rq_simple(rqp); - SMBERROR("%d\n", error); - if (error) + if (error) { + SMBERROR("smb_rq_simple(rqp) => error %d\n", error); break; + } } while(0); smb_rq_done(rqp); return error; diff -ruN RELENG_4/usr/src-orig/sys/fs/smbfs/smbfs_vnops.c RELENG_4/usr/src/sys/fs/smbfs/smbfs_vnops.c --- RELENG_4/usr/src-orig/sys/fs/smbfs/smbfs_vnops.c Wed Aug 31 11:24:30 2005 +++ RELENG_4/usr/src/sys/fs/smbfs/smbfs_vnops.c Wed Aug 31 22:11:39 2005 @@ -41,6 +41,7 @@ #include <sys/unistd.h> #include <sys/vnode.h> #include <sys/lockf.h> +#include <sys/stat.h> #include <machine/limits.h> @@ -332,6 +333,7 @@ struct smb_vc *vcp = SSTOVC(ssp); u_quad_t tsize = 0; int isreadonly, doclose, error = 0; + int old_n_dosattr; SMBVDEBUG("\n"); if (vap->va_flags != VNOVAL) @@ -377,6 +379,18 @@ return error; } } + if (vap->va_mode != (mode_t)VNOVAL) { + old_n_dosattr = np->n_dosattr; + if (vap->va_mode & S_IWUSR) + np->n_dosattr &= ~SMB_FA_RDONLY; + else + np->n_dosattr |= SMB_FA_RDONLY; + if (np->n_dosattr != old_n_dosattr) { + error = smbfs_smb_setpattr(np, np->n_dosattr, NULL, &scred); + if (error) + return error; + } + } mtime = atime = NULL; if (vap->va_mtime.tv_sec != VNOVAL) mtime = &vap->va_mtime; --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="smbfs_5.patch" diff -ruN RELENG_5/usr/src-orig/sys/fs/smbfs/smbfs_node.c RELENG_5/usr/src/sys/fs/smbfs/smbfs_node.c --- RELENG_5/usr/src-orig/sys/fs/smbfs/smbfs_node.c Wed Aug 31 11:23:54 2005 +++ RELENG_5/usr/src/sys/fs/smbfs/smbfs_node.c Wed Aug 31 21:50:41 2005 @@ -40,6 +40,7 @@ #include <sys/mount.h> #include <sys/proc.h> #include <sys/queue.h> +#include <sys/stat.h> #include <sys/sysctl.h> #include <sys/time.h> #include <sys/vnode.h> @@ -418,6 +419,8 @@ va->va_type = vp->v_type; /* vnode type (for create) */ if (vp->v_type == VREG) { va->va_mode = smp->sm_args.file_mode; /* files access mode and type */ + if (np->n_dosattr & SMB_FA_RDONLY) + va->va_mode &= ~(S_IWUSR|S_IWGRP|S_IWOTH); } else if (vp->v_type == VDIR) { va->va_mode = smp->sm_args.dir_mode; /* files access mode and type */ } else diff -ruN RELENG_5/usr/src-orig/sys/fs/smbfs/smbfs_smb.c RELENG_5/usr/src/sys/fs/smbfs/smbfs_smb.c --- RELENG_5/usr/src-orig/sys/fs/smbfs/smbfs_smb.c Wed Aug 31 11:23:54 2005 +++ RELENG_5/usr/src/sys/fs/smbfs/smbfs_smb.c Wed Aug 31 11:29:33 2005 @@ -512,9 +512,10 @@ mb_put_uint8(mbp, 0); smb_rq_bend(rqp); error = smb_rq_simple(rqp); - SMBERROR("%d\n", error); - if (error) + if (error) { + SMBERROR("smb_rq_simple(rqp) => error %d\n", error); break; + } } while(0); smb_rq_done(rqp); return error; diff -ruN RELENG_5/usr/src-orig/sys/fs/smbfs/smbfs_vnops.c RELENG_5/usr/src/sys/fs/smbfs/smbfs_vnops.c --- RELENG_5/usr/src-orig/sys/fs/smbfs/smbfs_vnops.c Wed Aug 31 11:23:55 2005 +++ RELENG_5/usr/src/sys/fs/smbfs/smbfs_vnops.c Wed Aug 31 22:11:55 2005 @@ -44,6 +44,7 @@ #include <sys/vnode.h> #include <sys/limits.h> #include <sys/lockf.h> +#include <sys/stat.h> #include <vm/vm.h> #include <vm/vm_extern.h> @@ -319,6 +320,7 @@ struct smb_vc *vcp = SSTOVC(ssp); u_quad_t tsize = 0; int isreadonly, doclose, error = 0; + int old_n_dosattr; SMBVDEBUG("\n"); if (vap->va_flags != VNOVAL) @@ -364,6 +366,18 @@ return error; } } + if (vap->va_mode != (mode_t)VNOVAL) { + old_n_dosattr = np->n_dosattr; + if (vap->va_mode & S_IWUSR) + np->n_dosattr &= ~SMB_FA_RDONLY; + else + np->n_dosattr |= SMB_FA_RDONLY; + if (np->n_dosattr != old_n_dosattr) { + error = smbfs_smb_setpattr(np, np->n_dosattr, NULL, &scred); + if (error) + return error; + } + } mtime = atime = NULL; if (vap->va_mtime.tv_sec != VNOVAL) mtime = &vap->va_mtime; --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="smbfs_6.patch" diff -ruN RELENG_6/usr/src-orig/sys/fs/smbfs/smbfs_node.c RELENG_6/usr/src/sys/fs/smbfs/smbfs_node.c --- RELENG_6/usr/src-orig/sys/fs/smbfs/smbfs_node.c Sun Mar 13 15:18:24 2005 +++ RELENG_6/usr/src/sys/fs/smbfs/smbfs_node.c Wed Aug 31 21:51:10 2005 @@ -40,6 +40,7 @@ #include <sys/mount.h> #include <sys/proc.h> #include <sys/queue.h> +#include <sys/stat.h> #include <sys/sysctl.h> #include <sys/time.h> #include <sys/vnode.h> @@ -418,6 +419,8 @@ va->va_type = vp->v_type; /* vnode type (for create) */ if (vp->v_type == VREG) { va->va_mode = smp->sm_file_mode; /* files access mode and type */ + if (np->n_dosattr & SMB_FA_RDONLY) + va->va_mode &= ~(S_IWUSR|S_IWGRP|S_IWOTH); } else if (vp->v_type == VDIR) { va->va_mode = smp->sm_dir_mode; /* files access mode and type */ } else diff -ruN RELENG_6/usr/src-orig/sys/fs/smbfs/smbfs_smb.c RELENG_6/usr/src/sys/fs/smbfs/smbfs_smb.c --- RELENG_6/usr/src-orig/sys/fs/smbfs/smbfs_smb.c Wed May 4 19:05:46 2005 +++ RELENG_6/usr/src/sys/fs/smbfs/smbfs_smb.c Wed Aug 31 11:30:44 2005 @@ -512,9 +512,10 @@ mb_put_uint8(mbp, 0); smb_rq_bend(rqp); error = smb_rq_simple(rqp); - SMBERROR("%d\n", error); - if (error) + if (error) { + SMBERROR("smb_rq_simple(rqp) => error %d\n", error); break; + } } while(0); smb_rq_done(rqp); return error; diff -ruN RELENG_6/usr/src-orig/sys/fs/smbfs/smbfs_vnops.c RELENG_6/usr/src/sys/fs/smbfs/smbfs_vnops.c --- RELENG_6/usr/src-orig/sys/fs/smbfs/smbfs_vnops.c Wed Apr 13 14:59:08 2005 +++ RELENG_6/usr/src/sys/fs/smbfs/smbfs_vnops.c Wed Aug 31 22:12:22 2005 @@ -44,6 +44,7 @@ #include <sys/vnode.h> #include <sys/limits.h> #include <sys/lockf.h> +#include <sys/stat.h> #include <vm/vm.h> #include <vm/vm_extern.h> @@ -301,6 +302,7 @@ struct smb_vc *vcp = SSTOVC(ssp); u_quad_t tsize = 0; int isreadonly, doclose, error = 0; + int old_n_dosattr; SMBVDEBUG("\n"); if (vap->va_flags != VNOVAL) @@ -346,6 +348,18 @@ return error; } } + if (vap->va_mode != (mode_t)VNOVAL) { + old_n_dosattr = np->n_dosattr; + if (vap->va_mode & S_IWUSR) + np->n_dosattr &= ~SMB_FA_RDONLY; + else + np->n_dosattr |= SMB_FA_RDONLY; + if (np->n_dosattr != old_n_dosattr) { + error = smbfs_smb_setpattr(np, np->n_dosattr, NULL, &scred); + if (error) + return error; + } + } mtime = atime = NULL; if (vap->va_mtime.tv_sec != VNOVAL) mtime = &vap->va_mtime; --SUOF0GtieIMvvwua--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508312110.j7VLAPOu003762>