2005-01-06 18:10:42 +00:00
|
|
|
/*-
|
2001-04-10 07:59:06 +00:00
|
|
|
* Copyright (c) 2000-2001 Boris Popov
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2012-10-31 03:55:33 +00:00
|
|
|
#include <sys/fnv_hash.h>
|
2001-04-10 07:59:06 +00:00
|
|
|
#include <sys/kernel.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/lock.h>
|
2001-04-10 07:59:06 +00:00
|
|
|
#include <sys/malloc.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/proc.h>
|
2001-04-10 07:59:06 +00:00
|
|
|
#include <sys/queue.h>
|
2006-11-05 06:38:42 +00:00
|
|
|
#include <sys/stat.h>
|
2008-03-02 18:56:13 +00:00
|
|
|
#include <sys/sx.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/vnode.h>
|
2001-04-10 07:59:06 +00:00
|
|
|
|
|
|
|
#include <netsmb/smb.h>
|
|
|
|
#include <netsmb/smb_conn.h>
|
|
|
|
#include <netsmb/smb_subr.h>
|
|
|
|
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_extern.h>
|
|
|
|
/*#include <vm/vm_page.h>
|
|
|
|
#include <vm/vm_object.h>*/
|
|
|
|
|
2001-04-10 07:59:06 +00:00
|
|
|
#include <fs/smbfs/smbfs.h>
|
|
|
|
#include <fs/smbfs/smbfs_node.h>
|
|
|
|
#include <fs/smbfs/smbfs_subr.h>
|
|
|
|
|
2004-12-01 23:16:38 +00:00
|
|
|
extern struct vop_vector smbfs_vnodeops; /* XXX -> .h file */
|
2001-04-10 07:59:06 +00:00
|
|
|
|
2011-11-07 06:44:47 +00:00
|
|
|
static MALLOC_DEFINE(M_SMBNODE, "smbufs_node", "SMBFS vnode private part");
|
2005-10-31 15:41:29 +00:00
|
|
|
static MALLOC_DEFINE(M_SMBNODENAME, "smbufs_nname", "SMBFS node name");
|
2001-04-10 07:59:06 +00:00
|
|
|
|
2012-10-31 03:55:33 +00:00
|
|
|
u_int32_t __inline
|
2001-04-10 07:59:06 +00:00
|
|
|
smbfs_hash(const u_char *name, int nmlen)
|
|
|
|
{
|
2012-10-31 03:55:33 +00:00
|
|
|
return (fnv_32_buf(name, nmlen, FNV1_32_INIT));
|
2001-04-10 07:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
smbfs_name_alloc(const u_char *name, int nmlen)
|
|
|
|
{
|
|
|
|
u_char *cp;
|
|
|
|
|
|
|
|
nmlen++;
|
2003-02-19 05:47:46 +00:00
|
|
|
cp = malloc(nmlen, M_SMBNODENAME, M_WAITOK);
|
2001-04-10 07:59:06 +00:00
|
|
|
bcopy(name, cp, nmlen - 1);
|
|
|
|
cp[nmlen - 1] = 0;
|
|
|
|
return cp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
smbfs_name_free(u_char *name)
|
|
|
|
{
|
|
|
|
|
|
|
|
free(name, M_SMBNODENAME);
|
|
|
|
}
|
|
|
|
|
2012-10-31 03:55:33 +00:00
|
|
|
static int __inline
|
|
|
|
smbfs_vnode_cmp(struct vnode *vp, void *_sc)
|
|
|
|
{
|
|
|
|
struct smbnode *np;
|
|
|
|
struct smbcmp *sc;
|
|
|
|
|
2013-06-28 20:32:48 +00:00
|
|
|
np = (struct smbnode *) vp->v_data;
|
2012-10-31 03:55:33 +00:00
|
|
|
sc = (struct smbcmp *) _sc;
|
|
|
|
if (np->n_parent != sc->n_parent || np->n_nmlen != sc->n_nmlen ||
|
|
|
|
bcmp(sc->n_name, np->n_name, sc->n_nmlen) != 0)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-04-10 07:59:06 +00:00
|
|
|
static int
|
2012-11-22 08:58:29 +00:00
|
|
|
smbfs_node_alloc(struct mount *mp, struct vnode *dvp, const char *dirnm,
|
|
|
|
int dirlen, const char *name, int nmlen, char sep,
|
|
|
|
struct smbfattr *fap, struct vnode **vpp)
|
2001-04-10 07:59:06 +00:00
|
|
|
{
|
2004-02-10 05:53:02 +00:00
|
|
|
struct vattr vattr;
|
2001-12-02 08:56:58 +00:00
|
|
|
struct thread *td = curthread; /* XXX */
|
2001-04-10 07:59:06 +00:00
|
|
|
struct smbmount *smp = VFSTOSMBFS(mp);
|
2012-10-31 03:55:33 +00:00
|
|
|
struct smbnode *np, *dnp;
|
|
|
|
struct vnode *vp, *vp2;
|
|
|
|
struct smbcmp sc;
|
2012-11-22 08:58:29 +00:00
|
|
|
char *p, *rpath;
|
|
|
|
int error, rplen;
|
2001-04-10 07:59:06 +00:00
|
|
|
|
2012-10-31 03:55:33 +00:00
|
|
|
sc.n_parent = dvp;
|
|
|
|
sc.n_nmlen = nmlen;
|
|
|
|
sc.n_name = name;
|
2001-04-10 07:59:06 +00:00
|
|
|
if (smp->sm_root != NULL && dvp == NULL) {
|
|
|
|
SMBERROR("do not allocate root vnode twice!\n");
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
if (nmlen == 2 && bcmp(name, "..", 2) == 0) {
|
|
|
|
if (dvp == NULL)
|
|
|
|
return EINVAL;
|
2002-12-13 10:15:01 +00:00
|
|
|
vp = VTOSMB(VTOSMB(dvp)->n_parent)->n_vnode;
|
2001-12-02 08:56:58 +00:00
|
|
|
error = vget(vp, LK_EXCLUSIVE, td);
|
2001-04-10 07:59:06 +00:00
|
|
|
if (error == 0)
|
|
|
|
*vpp = vp;
|
|
|
|
return error;
|
|
|
|
} else if (nmlen == 1 && name[0] == '.') {
|
|
|
|
SMBERROR("do not call me with dot!\n");
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
dnp = dvp ? VTOSMB(dvp) : NULL;
|
|
|
|
if (dnp == NULL && dvp != NULL) {
|
|
|
|
vprint("smbfs_node_alloc: dead parent vnode", dvp);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
2012-10-31 03:55:33 +00:00
|
|
|
error = vfs_hash_get(mp, smbfs_hash(name, nmlen), LK_EXCLUSIVE, td,
|
|
|
|
vpp, smbfs_vnode_cmp, &sc);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (*vpp) {
|
|
|
|
np = VTOSMB(*vpp);
|
2004-02-10 05:53:02 +00:00
|
|
|
/* Force cached attributes to be refreshed if stale. */
|
2012-10-31 03:55:33 +00:00
|
|
|
(void)VOP_GETATTR(*vpp, &vattr, td->td_ucred);
|
2004-02-10 05:53:02 +00:00
|
|
|
/*
|
|
|
|
* If the file type on the server is inconsistent with
|
|
|
|
* what it was when we created the vnode, kill the
|
|
|
|
* bogus vnode now and fall through to the code below
|
|
|
|
* to create a new one with the right type.
|
|
|
|
*/
|
2012-10-31 03:55:33 +00:00
|
|
|
if (((*vpp)->v_type == VDIR &&
|
|
|
|
(np->n_dosattr & SMB_FA_DIR) == 0) ||
|
|
|
|
((*vpp)->v_type == VREG &&
|
|
|
|
(np->n_dosattr & SMB_FA_DIR) != 0)) {
|
|
|
|
vgone(*vpp);
|
|
|
|
vput(*vpp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SMBVDEBUG("vnode taken from the hashtable\n");
|
|
|
|
return (0);
|
2004-02-10 05:53:02 +00:00
|
|
|
}
|
2001-04-10 07:59:06 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If we don't have node attributes, then it is an explicit lookup
|
|
|
|
* for an existing vnode.
|
|
|
|
*/
|
|
|
|
if (fap == NULL)
|
|
|
|
return ENOENT;
|
|
|
|
|
2012-10-31 03:55:33 +00:00
|
|
|
error = getnewvnode("smbfs", mp, &smbfs_vnodeops, vpp);
|
|
|
|
if (error)
|
2007-03-13 01:50:27 +00:00
|
|
|
return (error);
|
2012-10-31 03:55:33 +00:00
|
|
|
vp = *vpp;
|
2012-07-16 22:07:29 +00:00
|
|
|
np = malloc(sizeof *np, M_SMBNODE, M_WAITOK | M_ZERO);
|
2012-11-22 08:58:29 +00:00
|
|
|
rplen = dirlen;
|
|
|
|
if (sep != '\0')
|
|
|
|
rplen++;
|
|
|
|
rplen += nmlen;
|
|
|
|
rpath = malloc(rplen + 1, M_SMBNODENAME, M_WAITOK);
|
|
|
|
p = rpath;
|
|
|
|
bcopy(dirnm, p, dirlen);
|
|
|
|
p += dirlen;
|
|
|
|
if (sep != '\0')
|
|
|
|
*p++ = sep;
|
|
|
|
if (name != NULL) {
|
|
|
|
bcopy(name, p, nmlen);
|
|
|
|
p += nmlen;
|
|
|
|
}
|
2012-11-26 04:29:47 +00:00
|
|
|
*p = '\0';
|
2012-11-22 08:58:29 +00:00
|
|
|
MPASS(p == rpath + rplen);
|
2012-10-31 03:55:33 +00:00
|
|
|
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL);
|
|
|
|
/* Vnode initialization */
|
2001-04-10 07:59:06 +00:00
|
|
|
vp->v_type = fap->fa_attr & SMB_FA_DIR ? VDIR : VREG;
|
|
|
|
vp->v_data = np;
|
|
|
|
np->n_vnode = vp;
|
|
|
|
np->n_mount = VFSTOSMBFS(mp);
|
2012-11-22 08:58:29 +00:00
|
|
|
np->n_rpath = rpath;
|
|
|
|
np->n_rplen = rplen;
|
2001-04-10 07:59:06 +00:00
|
|
|
np->n_nmlen = nmlen;
|
|
|
|
np->n_name = smbfs_name_alloc(name, nmlen);
|
|
|
|
np->n_ino = fap->fa_ino;
|
|
|
|
if (dvp) {
|
2002-08-04 10:29:36 +00:00
|
|
|
ASSERT_VOP_LOCKED(dvp, "smbfs_node_alloc");
|
2002-12-13 10:15:01 +00:00
|
|
|
np->n_parent = dvp;
|
2012-11-22 08:58:29 +00:00
|
|
|
np->n_parentino = VTOSMB(dvp)->n_ino;
|
2002-08-04 10:29:36 +00:00
|
|
|
if (/*vp->v_type == VDIR &&*/ (dvp->v_vflag & VV_ROOT) == 0) {
|
2001-04-10 07:59:06 +00:00
|
|
|
vref(dvp);
|
|
|
|
np->n_flag |= NREFPARENT;
|
|
|
|
}
|
|
|
|
} else if (vp->v_type == VREG)
|
|
|
|
SMBERROR("new vnode '%s' born without parent ?\n", np->n_name);
|
2012-10-31 03:55:33 +00:00
|
|
|
error = insmntque(vp, mp);
|
|
|
|
if (error) {
|
|
|
|
free(np, M_SMBNODE);
|
|
|
|
return (error);
|
2001-04-10 07:59:06 +00:00
|
|
|
}
|
2012-10-31 03:55:33 +00:00
|
|
|
error = vfs_hash_insert(vp, smbfs_hash(name, nmlen), LK_EXCLUSIVE,
|
|
|
|
td, &vp2, smbfs_vnode_cmp, &sc);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (vp2 != NULL)
|
|
|
|
*vpp = vp2;
|
|
|
|
return (0);
|
2001-04-10 07:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
smbfs_nget(struct mount *mp, struct vnode *dvp, const char *name, int nmlen,
|
|
|
|
struct smbfattr *fap, struct vnode **vpp)
|
|
|
|
{
|
2012-11-22 08:58:29 +00:00
|
|
|
struct smbnode *dnp, *np;
|
2001-04-10 07:59:06 +00:00
|
|
|
struct vnode *vp;
|
2012-11-22 08:58:29 +00:00
|
|
|
int error, sep;
|
2001-04-10 07:59:06 +00:00
|
|
|
|
2012-11-22 08:58:29 +00:00
|
|
|
dnp = (dvp) ? VTOSMB(dvp) : NULL;
|
|
|
|
sep = 0;
|
|
|
|
if (dnp != NULL) {
|
|
|
|
sep = SMBFS_DNP_SEP(dnp);
|
|
|
|
error = smbfs_node_alloc(mp, dvp, dnp->n_rpath, dnp->n_rplen,
|
|
|
|
name, nmlen, sep, fap, &vp);
|
|
|
|
} else
|
|
|
|
error = smbfs_node_alloc(mp, NULL, "\\", 1, name, nmlen,
|
|
|
|
sep, fap, &vp);
|
2001-04-10 07:59:06 +00:00
|
|
|
if (error)
|
|
|
|
return error;
|
2012-11-22 08:58:29 +00:00
|
|
|
MPASS(vp != NULL);
|
2001-04-10 07:59:06 +00:00
|
|
|
np = VTOSMB(vp);
|
|
|
|
if (fap)
|
|
|
|
smbfs_attr_cacheenter(vp, fap);
|
|
|
|
*vpp = vp;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free smbnode, and give vnode back to system
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
smbfs_reclaim(ap)
|
|
|
|
struct vop_reclaim_args /* {
|
|
|
|
struct vnode *a_vp;
|
2001-12-02 08:56:58 +00:00
|
|
|
struct thread *a_p;
|
2001-04-10 07:59:06 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct vnode *dvp;
|
|
|
|
struct smbnode *np = VTOSMB(vp);
|
|
|
|
struct smbmount *smp = VTOSMBFS(vp);
|
|
|
|
|
2002-09-25 02:32:42 +00:00
|
|
|
SMBVDEBUG("%s,%d\n", np->n_name, vrefcnt(vp));
|
2001-04-10 07:59:06 +00:00
|
|
|
|
2003-06-17 12:58:02 +00:00
|
|
|
KASSERT((np->n_flag & NOPEN) == 0, ("file not closed before reclaim"));
|
|
|
|
|
2006-01-17 17:29:03 +00:00
|
|
|
/*
|
|
|
|
* Destroy the vm object and flush associated pages.
|
|
|
|
*/
|
|
|
|
vnode_destroy_vobject(vp);
|
2001-04-10 07:59:06 +00:00
|
|
|
dvp = (np->n_parent && (np->n_flag & NREFPARENT)) ?
|
2002-12-13 10:15:01 +00:00
|
|
|
np->n_parent : NULL;
|
2012-10-31 03:55:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove the vnode from its hash chain.
|
|
|
|
*/
|
|
|
|
vfs_hash_remove(vp);
|
2001-04-10 07:59:06 +00:00
|
|
|
if (np->n_name)
|
|
|
|
smbfs_name_free(np->n_name);
|
2012-11-22 08:58:29 +00:00
|
|
|
if (np->n_rpath)
|
|
|
|
free(np->n_rpath, M_SMBNODENAME);
|
2008-10-23 15:53:51 +00:00
|
|
|
free(np, M_SMBNODE);
|
2012-10-31 03:55:33 +00:00
|
|
|
vp->v_data = NULL;
|
2002-12-15 04:32:41 +00:00
|
|
|
if (dvp != NULL) {
|
|
|
|
vrele(dvp);
|
|
|
|
/*
|
|
|
|
* Indicate that we released something; see comment
|
|
|
|
* in smbfs_unmount().
|
|
|
|
*/
|
|
|
|
smp->sm_didrele = 1;
|
2001-04-10 07:59:06 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
smbfs_inactive(ap)
|
|
|
|
struct vop_inactive_args /* {
|
|
|
|
struct vnode *a_vp;
|
2001-12-02 08:56:58 +00:00
|
|
|
struct thread *a_td;
|
2001-04-10 07:59:06 +00:00
|
|
|
} */ *ap;
|
|
|
|
{
|
2001-12-02 08:56:58 +00:00
|
|
|
struct thread *td = ap->a_td;
|
2002-02-27 18:32:23 +00:00
|
|
|
struct ucred *cred = td->td_ucred;
|
2001-04-10 07:59:06 +00:00
|
|
|
struct vnode *vp = ap->a_vp;
|
|
|
|
struct smbnode *np = VTOSMB(vp);
|
2012-10-31 03:34:07 +00:00
|
|
|
struct smb_cred *scred;
|
2003-06-17 12:58:02 +00:00
|
|
|
struct vattr va;
|
2001-04-10 07:59:06 +00:00
|
|
|
|
2002-09-25 02:32:42 +00:00
|
|
|
SMBVDEBUG("%s: %d\n", VTOSMB(vp)->n_name, vrefcnt(vp));
|
2003-06-17 12:58:02 +00:00
|
|
|
if ((np->n_flag & NOPEN) != 0) {
|
2012-10-31 03:34:07 +00:00
|
|
|
scred = smbfs_malloc_scred();
|
|
|
|
smb_makescred(scred, td, cred);
|
2005-01-14 08:52:55 +00:00
|
|
|
smbfs_vinvalbuf(vp, td);
|
2003-06-17 12:58:02 +00:00
|
|
|
if (vp->v_type == VREG) {
|
2008-08-28 15:23:18 +00:00
|
|
|
VOP_GETATTR(vp, &va, cred);
|
2003-06-17 12:58:02 +00:00
|
|
|
smbfs_smb_close(np->n_mount->sm_share, np->n_fid,
|
2012-10-31 03:34:07 +00:00
|
|
|
&np->n_mtime, scred);
|
2003-06-17 12:58:02 +00:00
|
|
|
} else if (vp->v_type == VDIR) {
|
|
|
|
if (np->n_dirseq != NULL) {
|
2012-10-31 03:34:07 +00:00
|
|
|
smbfs_findclose(np->n_dirseq, scred);
|
2003-06-17 12:58:02 +00:00
|
|
|
np->n_dirseq = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
np->n_flag &= ~NOPEN;
|
2004-01-04 00:57:22 +00:00
|
|
|
smbfs_attr_cacheremove(vp);
|
2012-10-31 03:34:07 +00:00
|
|
|
smbfs_free_scred(scred);
|
2001-04-10 07:59:06 +00:00
|
|
|
}
|
2004-02-10 05:53:02 +00:00
|
|
|
if (np->n_flag & NGONE)
|
2012-04-23 14:10:34 +00:00
|
|
|
vrecycle(vp);
|
2001-04-10 07:59:06 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* routines to maintain vnode attributes cache
|
|
|
|
* smbfs_attr_cacheenter: unpack np.i to vattr structure
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
smbfs_attr_cacheenter(struct vnode *vp, struct smbfattr *fap)
|
|
|
|
{
|
|
|
|
struct smbnode *np = VTOSMB(vp);
|
|
|
|
|
|
|
|
if (vp->v_type == VREG) {
|
|
|
|
if (np->n_size != fap->fa_size) {
|
|
|
|
np->n_size = fap->fa_size;
|
|
|
|
vnode_pager_setsize(vp, np->n_size);
|
|
|
|
}
|
|
|
|
} else if (vp->v_type == VDIR) {
|
|
|
|
np->n_size = 16384; /* should be a better way ... */
|
|
|
|
} else
|
|
|
|
return;
|
|
|
|
np->n_mtime = fap->fa_mtime;
|
|
|
|
np->n_dosattr = fap->fa_attr;
|
|
|
|
np->n_attrage = time_second;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
smbfs_attr_cachelookup(struct vnode *vp, struct vattr *va)
|
|
|
|
{
|
|
|
|
struct smbnode *np = VTOSMB(vp);
|
|
|
|
struct smbmount *smp = VTOSMBFS(vp);
|
|
|
|
int diff;
|
|
|
|
|
|
|
|
diff = time_second - np->n_attrage;
|
|
|
|
if (diff > 2) /* XXX should be configurable */
|
|
|
|
return ENOENT;
|
|
|
|
va->va_type = vp->v_type; /* vnode type (for create) */
|
Expand the use of stat(2) flags to allow storing some Windows/DOS
and CIFS file attributes as BSD stat(2) flags.
This work is intended to be compatible with ZFS, the Solaris CIFS
server's interaction with ZFS, somewhat compatible with MacOS X,
and of course compatible with Windows.
The Windows attributes that are implemented were chosen based on
the attributes that ZFS already supports.
The summary of the flags is as follows:
UF_SYSTEM: Command line name: "system" or "usystem"
ZFS name: XAT_SYSTEM, ZFS_SYSTEM
Windows: FILE_ATTRIBUTE_SYSTEM
This flag means that the file is used by the
operating system. FreeBSD does not enforce any
special handling when this flag is set.
UF_SPARSE: Command line name: "sparse" or "usparse"
ZFS name: XAT_SPARSE, ZFS_SPARSE
Windows: FILE_ATTRIBUTE_SPARSE_FILE
This flag means that the file is sparse. Although
ZFS may modify this in some situations, there is
not generally any special handling for this flag.
UF_OFFLINE: Command line name: "offline" or "uoffline"
ZFS name: XAT_OFFLINE, ZFS_OFFLINE
Windows: FILE_ATTRIBUTE_OFFLINE
This flag means that the file has been moved to
offline storage. FreeBSD does not have any special
handling for this flag.
UF_REPARSE: Command line name: "reparse" or "ureparse"
ZFS name: XAT_REPARSE, ZFS_REPARSE
Windows: FILE_ATTRIBUTE_REPARSE_POINT
This flag means that the file is a Windows reparse
point. ZFS has special handling code for reparse
points, but we don't currently have the other
supporting infrastructure for them.
UF_HIDDEN: Command line name: "hidden" or "uhidden"
ZFS name: XAT_HIDDEN, ZFS_HIDDEN
Windows: FILE_ATTRIBUTE_HIDDEN
This flag means that the file may be excluded from
a directory listing if the application honors it.
FreeBSD has no special handling for this flag.
The name and bit definition for UF_HIDDEN are
identical to the definition in MacOS X.
UF_READONLY: Command line name: "urdonly", "rdonly", "readonly"
ZFS name: XAT_READONLY, ZFS_READONLY
Windows: FILE_ATTRIBUTE_READONLY
This flag means that the file may not written or
appended, but its attributes may be changed.
ZFS currently enforces this flag, but Illumos
developers have discussed disabling enforcement.
The behavior of this flag is different than MacOS X.
MacOS X uses UF_IMMUTABLE to represent the DOS
readonly permission, but that flag has a stronger
meaning than the semantics of DOS readonly permissions.
UF_ARCHIVE: Command line name: "uarch", "uarchive"
ZFS_NAME: XAT_ARCHIVE, ZFS_ARCHIVE
Windows name: FILE_ATTRIBUTE_ARCHIVE
The UF_ARCHIVED flag means that the file has changed and
needs to be archived. The meaning is same as
the Windows FILE_ATTRIBUTE_ARCHIVE attribute, and
the ZFS XAT_ARCHIVE and ZFS_ARCHIVE attribute.
msdosfs and ZFS have special handling for this flag.
i.e. they will set it when the file changes.
sys/param.h: Bump __FreeBSD_version to 1000047 for the
addition of new stat(2) flags.
chflags.1: Document the new command line flag names
(e.g. "system", "hidden") available to the
user.
ls.1: Reference chflags(1) for a list of file flags
and their meanings.
strtofflags.c: Implement the mapping between the new
command line flag names and new stat(2)
flags.
chflags.2: Document all of the new stat(2) flags, and
explain the intended behavior in a little
more detail. Explain how they map to
Windows file attributes.
Different filesystems behave differently
with respect to flags, so warn the
application developer to take care when
using them.
zfs_vnops.c: Add support for getting and setting the
UF_ARCHIVE, UF_READONLY, UF_SYSTEM, UF_HIDDEN,
UF_REPARSE, UF_OFFLINE, and UF_SPARSE flags.
All of these flags are implemented using
attributes that ZFS already supports, so
the on-disk format has not changed.
ZFS currently doesn't allow setting the
UF_REPARSE flag, and we don't really have
the other infrastructure to support reparse
points.
msdosfs_denode.c,
msdosfs_vnops.c: Add support for getting and setting
UF_HIDDEN, UF_SYSTEM and UF_READONLY
in MSDOSFS.
It supported SF_ARCHIVED, but this has been
changed to be UF_ARCHIVE, which has the same
semantics as the DOS archive attribute instead
of inverse semantics like SF_ARCHIVED.
After discussion with Bruce Evans, change
several things in the msdosfs behavior:
Use UF_READONLY to indicate whether a file
is writeable instead of file permissions, but
don't actually enforce it.
Refuse to change attributes on the root
directory, because it is special in FAT
filesystems, but allow most other attribute
changes on directories.
Don't set the archive attribute on a directory
when its modification time is updated.
Windows and DOS don't set the archive attribute
in that scenario, so we are now bug-for-bug
compatible.
smbfs_node.c,
smbfs_vnops.c: Add support for UF_HIDDEN, UF_SYSTEM,
UF_READONLY and UF_ARCHIVE in SMBFS.
This is similar to changes that Apple has
made in their version of SMBFS (as of
smb-583.8, posted on opensource.apple.com),
but not quite the same.
We map SMB_FA_READONLY to UF_READONLY,
because UF_READONLY is intended to match
the semantics of the DOS readonly flag.
The MacOS X code maps both UF_IMMUTABLE
and SF_IMMUTABLE to SMB_FA_READONLY, but
the immutable flags have stronger meaning
than the DOS readonly bit.
stat.h: Add definitions for UF_SYSTEM, UF_SPARSE,
UF_OFFLINE, UF_REPARSE, UF_ARCHIVE, UF_READONLY
and UF_HIDDEN.
The definition of UF_HIDDEN is the same as
the MacOS X definition.
Add commented-out definitions of
UF_COMPRESSED and UF_TRACKED. They are
defined in MacOS X (as of 10.8.2), but we
do not implement them (yet).
ufs_vnops.c: Add support for getting and setting
UF_ARCHIVE, UF_HIDDEN, UF_OFFLINE, UF_READONLY,
UF_REPARSE, UF_SPARSE, and UF_SYSTEM in UFS.
Alphabetize the flags that are supported.
These new flags are only stored, UFS does
not take any action if the flag is set.
Sponsored by: Spectra Logic
Reviewed by: bde (earlier version)
2013-08-21 23:04:48 +00:00
|
|
|
va->va_flags = 0; /* flags defined for file */
|
2001-04-10 07:59:06 +00:00
|
|
|
if (vp->v_type == VREG) {
|
2004-12-06 20:31:08 +00:00
|
|
|
va->va_mode = smp->sm_file_mode; /* files access mode and type */
|
Expand the use of stat(2) flags to allow storing some Windows/DOS
and CIFS file attributes as BSD stat(2) flags.
This work is intended to be compatible with ZFS, the Solaris CIFS
server's interaction with ZFS, somewhat compatible with MacOS X,
and of course compatible with Windows.
The Windows attributes that are implemented were chosen based on
the attributes that ZFS already supports.
The summary of the flags is as follows:
UF_SYSTEM: Command line name: "system" or "usystem"
ZFS name: XAT_SYSTEM, ZFS_SYSTEM
Windows: FILE_ATTRIBUTE_SYSTEM
This flag means that the file is used by the
operating system. FreeBSD does not enforce any
special handling when this flag is set.
UF_SPARSE: Command line name: "sparse" or "usparse"
ZFS name: XAT_SPARSE, ZFS_SPARSE
Windows: FILE_ATTRIBUTE_SPARSE_FILE
This flag means that the file is sparse. Although
ZFS may modify this in some situations, there is
not generally any special handling for this flag.
UF_OFFLINE: Command line name: "offline" or "uoffline"
ZFS name: XAT_OFFLINE, ZFS_OFFLINE
Windows: FILE_ATTRIBUTE_OFFLINE
This flag means that the file has been moved to
offline storage. FreeBSD does not have any special
handling for this flag.
UF_REPARSE: Command line name: "reparse" or "ureparse"
ZFS name: XAT_REPARSE, ZFS_REPARSE
Windows: FILE_ATTRIBUTE_REPARSE_POINT
This flag means that the file is a Windows reparse
point. ZFS has special handling code for reparse
points, but we don't currently have the other
supporting infrastructure for them.
UF_HIDDEN: Command line name: "hidden" or "uhidden"
ZFS name: XAT_HIDDEN, ZFS_HIDDEN
Windows: FILE_ATTRIBUTE_HIDDEN
This flag means that the file may be excluded from
a directory listing if the application honors it.
FreeBSD has no special handling for this flag.
The name and bit definition for UF_HIDDEN are
identical to the definition in MacOS X.
UF_READONLY: Command line name: "urdonly", "rdonly", "readonly"
ZFS name: XAT_READONLY, ZFS_READONLY
Windows: FILE_ATTRIBUTE_READONLY
This flag means that the file may not written or
appended, but its attributes may be changed.
ZFS currently enforces this flag, but Illumos
developers have discussed disabling enforcement.
The behavior of this flag is different than MacOS X.
MacOS X uses UF_IMMUTABLE to represent the DOS
readonly permission, but that flag has a stronger
meaning than the semantics of DOS readonly permissions.
UF_ARCHIVE: Command line name: "uarch", "uarchive"
ZFS_NAME: XAT_ARCHIVE, ZFS_ARCHIVE
Windows name: FILE_ATTRIBUTE_ARCHIVE
The UF_ARCHIVED flag means that the file has changed and
needs to be archived. The meaning is same as
the Windows FILE_ATTRIBUTE_ARCHIVE attribute, and
the ZFS XAT_ARCHIVE and ZFS_ARCHIVE attribute.
msdosfs and ZFS have special handling for this flag.
i.e. they will set it when the file changes.
sys/param.h: Bump __FreeBSD_version to 1000047 for the
addition of new stat(2) flags.
chflags.1: Document the new command line flag names
(e.g. "system", "hidden") available to the
user.
ls.1: Reference chflags(1) for a list of file flags
and their meanings.
strtofflags.c: Implement the mapping between the new
command line flag names and new stat(2)
flags.
chflags.2: Document all of the new stat(2) flags, and
explain the intended behavior in a little
more detail. Explain how they map to
Windows file attributes.
Different filesystems behave differently
with respect to flags, so warn the
application developer to take care when
using them.
zfs_vnops.c: Add support for getting and setting the
UF_ARCHIVE, UF_READONLY, UF_SYSTEM, UF_HIDDEN,
UF_REPARSE, UF_OFFLINE, and UF_SPARSE flags.
All of these flags are implemented using
attributes that ZFS already supports, so
the on-disk format has not changed.
ZFS currently doesn't allow setting the
UF_REPARSE flag, and we don't really have
the other infrastructure to support reparse
points.
msdosfs_denode.c,
msdosfs_vnops.c: Add support for getting and setting
UF_HIDDEN, UF_SYSTEM and UF_READONLY
in MSDOSFS.
It supported SF_ARCHIVED, but this has been
changed to be UF_ARCHIVE, which has the same
semantics as the DOS archive attribute instead
of inverse semantics like SF_ARCHIVED.
After discussion with Bruce Evans, change
several things in the msdosfs behavior:
Use UF_READONLY to indicate whether a file
is writeable instead of file permissions, but
don't actually enforce it.
Refuse to change attributes on the root
directory, because it is special in FAT
filesystems, but allow most other attribute
changes on directories.
Don't set the archive attribute on a directory
when its modification time is updated.
Windows and DOS don't set the archive attribute
in that scenario, so we are now bug-for-bug
compatible.
smbfs_node.c,
smbfs_vnops.c: Add support for UF_HIDDEN, UF_SYSTEM,
UF_READONLY and UF_ARCHIVE in SMBFS.
This is similar to changes that Apple has
made in their version of SMBFS (as of
smb-583.8, posted on opensource.apple.com),
but not quite the same.
We map SMB_FA_READONLY to UF_READONLY,
because UF_READONLY is intended to match
the semantics of the DOS readonly flag.
The MacOS X code maps both UF_IMMUTABLE
and SF_IMMUTABLE to SMB_FA_READONLY, but
the immutable flags have stronger meaning
than the DOS readonly bit.
stat.h: Add definitions for UF_SYSTEM, UF_SPARSE,
UF_OFFLINE, UF_REPARSE, UF_ARCHIVE, UF_READONLY
and UF_HIDDEN.
The definition of UF_HIDDEN is the same as
the MacOS X definition.
Add commented-out definitions of
UF_COMPRESSED and UF_TRACKED. They are
defined in MacOS X (as of 10.8.2), but we
do not implement them (yet).
ufs_vnops.c: Add support for getting and setting
UF_ARCHIVE, UF_HIDDEN, UF_OFFLINE, UF_READONLY,
UF_REPARSE, UF_SPARSE, and UF_SYSTEM in UFS.
Alphabetize the flags that are supported.
These new flags are only stored, UFS does
not take any action if the flag is set.
Sponsored by: Spectra Logic
Reviewed by: bde (earlier version)
2013-08-21 23:04:48 +00:00
|
|
|
if (np->n_dosattr & SMB_FA_RDONLY) {
|
2006-11-05 06:38:42 +00:00
|
|
|
va->va_mode &= ~(S_IWUSR|S_IWGRP|S_IWOTH);
|
Expand the use of stat(2) flags to allow storing some Windows/DOS
and CIFS file attributes as BSD stat(2) flags.
This work is intended to be compatible with ZFS, the Solaris CIFS
server's interaction with ZFS, somewhat compatible with MacOS X,
and of course compatible with Windows.
The Windows attributes that are implemented were chosen based on
the attributes that ZFS already supports.
The summary of the flags is as follows:
UF_SYSTEM: Command line name: "system" or "usystem"
ZFS name: XAT_SYSTEM, ZFS_SYSTEM
Windows: FILE_ATTRIBUTE_SYSTEM
This flag means that the file is used by the
operating system. FreeBSD does not enforce any
special handling when this flag is set.
UF_SPARSE: Command line name: "sparse" or "usparse"
ZFS name: XAT_SPARSE, ZFS_SPARSE
Windows: FILE_ATTRIBUTE_SPARSE_FILE
This flag means that the file is sparse. Although
ZFS may modify this in some situations, there is
not generally any special handling for this flag.
UF_OFFLINE: Command line name: "offline" or "uoffline"
ZFS name: XAT_OFFLINE, ZFS_OFFLINE
Windows: FILE_ATTRIBUTE_OFFLINE
This flag means that the file has been moved to
offline storage. FreeBSD does not have any special
handling for this flag.
UF_REPARSE: Command line name: "reparse" or "ureparse"
ZFS name: XAT_REPARSE, ZFS_REPARSE
Windows: FILE_ATTRIBUTE_REPARSE_POINT
This flag means that the file is a Windows reparse
point. ZFS has special handling code for reparse
points, but we don't currently have the other
supporting infrastructure for them.
UF_HIDDEN: Command line name: "hidden" or "uhidden"
ZFS name: XAT_HIDDEN, ZFS_HIDDEN
Windows: FILE_ATTRIBUTE_HIDDEN
This flag means that the file may be excluded from
a directory listing if the application honors it.
FreeBSD has no special handling for this flag.
The name and bit definition for UF_HIDDEN are
identical to the definition in MacOS X.
UF_READONLY: Command line name: "urdonly", "rdonly", "readonly"
ZFS name: XAT_READONLY, ZFS_READONLY
Windows: FILE_ATTRIBUTE_READONLY
This flag means that the file may not written or
appended, but its attributes may be changed.
ZFS currently enforces this flag, but Illumos
developers have discussed disabling enforcement.
The behavior of this flag is different than MacOS X.
MacOS X uses UF_IMMUTABLE to represent the DOS
readonly permission, but that flag has a stronger
meaning than the semantics of DOS readonly permissions.
UF_ARCHIVE: Command line name: "uarch", "uarchive"
ZFS_NAME: XAT_ARCHIVE, ZFS_ARCHIVE
Windows name: FILE_ATTRIBUTE_ARCHIVE
The UF_ARCHIVED flag means that the file has changed and
needs to be archived. The meaning is same as
the Windows FILE_ATTRIBUTE_ARCHIVE attribute, and
the ZFS XAT_ARCHIVE and ZFS_ARCHIVE attribute.
msdosfs and ZFS have special handling for this flag.
i.e. they will set it when the file changes.
sys/param.h: Bump __FreeBSD_version to 1000047 for the
addition of new stat(2) flags.
chflags.1: Document the new command line flag names
(e.g. "system", "hidden") available to the
user.
ls.1: Reference chflags(1) for a list of file flags
and their meanings.
strtofflags.c: Implement the mapping between the new
command line flag names and new stat(2)
flags.
chflags.2: Document all of the new stat(2) flags, and
explain the intended behavior in a little
more detail. Explain how they map to
Windows file attributes.
Different filesystems behave differently
with respect to flags, so warn the
application developer to take care when
using them.
zfs_vnops.c: Add support for getting and setting the
UF_ARCHIVE, UF_READONLY, UF_SYSTEM, UF_HIDDEN,
UF_REPARSE, UF_OFFLINE, and UF_SPARSE flags.
All of these flags are implemented using
attributes that ZFS already supports, so
the on-disk format has not changed.
ZFS currently doesn't allow setting the
UF_REPARSE flag, and we don't really have
the other infrastructure to support reparse
points.
msdosfs_denode.c,
msdosfs_vnops.c: Add support for getting and setting
UF_HIDDEN, UF_SYSTEM and UF_READONLY
in MSDOSFS.
It supported SF_ARCHIVED, but this has been
changed to be UF_ARCHIVE, which has the same
semantics as the DOS archive attribute instead
of inverse semantics like SF_ARCHIVED.
After discussion with Bruce Evans, change
several things in the msdosfs behavior:
Use UF_READONLY to indicate whether a file
is writeable instead of file permissions, but
don't actually enforce it.
Refuse to change attributes on the root
directory, because it is special in FAT
filesystems, but allow most other attribute
changes on directories.
Don't set the archive attribute on a directory
when its modification time is updated.
Windows and DOS don't set the archive attribute
in that scenario, so we are now bug-for-bug
compatible.
smbfs_node.c,
smbfs_vnops.c: Add support for UF_HIDDEN, UF_SYSTEM,
UF_READONLY and UF_ARCHIVE in SMBFS.
This is similar to changes that Apple has
made in their version of SMBFS (as of
smb-583.8, posted on opensource.apple.com),
but not quite the same.
We map SMB_FA_READONLY to UF_READONLY,
because UF_READONLY is intended to match
the semantics of the DOS readonly flag.
The MacOS X code maps both UF_IMMUTABLE
and SF_IMMUTABLE to SMB_FA_READONLY, but
the immutable flags have stronger meaning
than the DOS readonly bit.
stat.h: Add definitions for UF_SYSTEM, UF_SPARSE,
UF_OFFLINE, UF_REPARSE, UF_ARCHIVE, UF_READONLY
and UF_HIDDEN.
The definition of UF_HIDDEN is the same as
the MacOS X definition.
Add commented-out definitions of
UF_COMPRESSED and UF_TRACKED. They are
defined in MacOS X (as of 10.8.2), but we
do not implement them (yet).
ufs_vnops.c: Add support for getting and setting
UF_ARCHIVE, UF_HIDDEN, UF_OFFLINE, UF_READONLY,
UF_REPARSE, UF_SPARSE, and UF_SYSTEM in UFS.
Alphabetize the flags that are supported.
These new flags are only stored, UFS does
not take any action if the flag is set.
Sponsored by: Spectra Logic
Reviewed by: bde (earlier version)
2013-08-21 23:04:48 +00:00
|
|
|
va->va_flags |= UF_READONLY;
|
|
|
|
}
|
2001-04-10 07:59:06 +00:00
|
|
|
} else if (vp->v_type == VDIR) {
|
2004-12-06 20:31:08 +00:00
|
|
|
va->va_mode = smp->sm_dir_mode; /* files access mode and type */
|
2001-04-10 07:59:06 +00:00
|
|
|
} else
|
|
|
|
return EINVAL;
|
|
|
|
va->va_size = np->n_size;
|
|
|
|
va->va_nlink = 1; /* number of references to file */
|
2004-12-06 20:31:08 +00:00
|
|
|
va->va_uid = smp->sm_uid; /* owner user id */
|
|
|
|
va->va_gid = smp->sm_gid; /* owner group id */
|
2001-04-10 07:59:06 +00:00
|
|
|
va->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
|
|
|
|
va->va_fileid = np->n_ino; /* file id */
|
|
|
|
if (va->va_fileid == 0)
|
|
|
|
va->va_fileid = 2;
|
|
|
|
va->va_blocksize = SSTOVC(smp->sm_share)->vc_txmax;
|
|
|
|
va->va_mtime = np->n_mtime;
|
|
|
|
va->va_atime = va->va_ctime = va->va_mtime; /* time file changed */
|
|
|
|
va->va_gen = VNOVAL; /* generation number of file */
|
Expand the use of stat(2) flags to allow storing some Windows/DOS
and CIFS file attributes as BSD stat(2) flags.
This work is intended to be compatible with ZFS, the Solaris CIFS
server's interaction with ZFS, somewhat compatible with MacOS X,
and of course compatible with Windows.
The Windows attributes that are implemented were chosen based on
the attributes that ZFS already supports.
The summary of the flags is as follows:
UF_SYSTEM: Command line name: "system" or "usystem"
ZFS name: XAT_SYSTEM, ZFS_SYSTEM
Windows: FILE_ATTRIBUTE_SYSTEM
This flag means that the file is used by the
operating system. FreeBSD does not enforce any
special handling when this flag is set.
UF_SPARSE: Command line name: "sparse" or "usparse"
ZFS name: XAT_SPARSE, ZFS_SPARSE
Windows: FILE_ATTRIBUTE_SPARSE_FILE
This flag means that the file is sparse. Although
ZFS may modify this in some situations, there is
not generally any special handling for this flag.
UF_OFFLINE: Command line name: "offline" or "uoffline"
ZFS name: XAT_OFFLINE, ZFS_OFFLINE
Windows: FILE_ATTRIBUTE_OFFLINE
This flag means that the file has been moved to
offline storage. FreeBSD does not have any special
handling for this flag.
UF_REPARSE: Command line name: "reparse" or "ureparse"
ZFS name: XAT_REPARSE, ZFS_REPARSE
Windows: FILE_ATTRIBUTE_REPARSE_POINT
This flag means that the file is a Windows reparse
point. ZFS has special handling code for reparse
points, but we don't currently have the other
supporting infrastructure for them.
UF_HIDDEN: Command line name: "hidden" or "uhidden"
ZFS name: XAT_HIDDEN, ZFS_HIDDEN
Windows: FILE_ATTRIBUTE_HIDDEN
This flag means that the file may be excluded from
a directory listing if the application honors it.
FreeBSD has no special handling for this flag.
The name and bit definition for UF_HIDDEN are
identical to the definition in MacOS X.
UF_READONLY: Command line name: "urdonly", "rdonly", "readonly"
ZFS name: XAT_READONLY, ZFS_READONLY
Windows: FILE_ATTRIBUTE_READONLY
This flag means that the file may not written or
appended, but its attributes may be changed.
ZFS currently enforces this flag, but Illumos
developers have discussed disabling enforcement.
The behavior of this flag is different than MacOS X.
MacOS X uses UF_IMMUTABLE to represent the DOS
readonly permission, but that flag has a stronger
meaning than the semantics of DOS readonly permissions.
UF_ARCHIVE: Command line name: "uarch", "uarchive"
ZFS_NAME: XAT_ARCHIVE, ZFS_ARCHIVE
Windows name: FILE_ATTRIBUTE_ARCHIVE
The UF_ARCHIVED flag means that the file has changed and
needs to be archived. The meaning is same as
the Windows FILE_ATTRIBUTE_ARCHIVE attribute, and
the ZFS XAT_ARCHIVE and ZFS_ARCHIVE attribute.
msdosfs and ZFS have special handling for this flag.
i.e. they will set it when the file changes.
sys/param.h: Bump __FreeBSD_version to 1000047 for the
addition of new stat(2) flags.
chflags.1: Document the new command line flag names
(e.g. "system", "hidden") available to the
user.
ls.1: Reference chflags(1) for a list of file flags
and their meanings.
strtofflags.c: Implement the mapping between the new
command line flag names and new stat(2)
flags.
chflags.2: Document all of the new stat(2) flags, and
explain the intended behavior in a little
more detail. Explain how they map to
Windows file attributes.
Different filesystems behave differently
with respect to flags, so warn the
application developer to take care when
using them.
zfs_vnops.c: Add support for getting and setting the
UF_ARCHIVE, UF_READONLY, UF_SYSTEM, UF_HIDDEN,
UF_REPARSE, UF_OFFLINE, and UF_SPARSE flags.
All of these flags are implemented using
attributes that ZFS already supports, so
the on-disk format has not changed.
ZFS currently doesn't allow setting the
UF_REPARSE flag, and we don't really have
the other infrastructure to support reparse
points.
msdosfs_denode.c,
msdosfs_vnops.c: Add support for getting and setting
UF_HIDDEN, UF_SYSTEM and UF_READONLY
in MSDOSFS.
It supported SF_ARCHIVED, but this has been
changed to be UF_ARCHIVE, which has the same
semantics as the DOS archive attribute instead
of inverse semantics like SF_ARCHIVED.
After discussion with Bruce Evans, change
several things in the msdosfs behavior:
Use UF_READONLY to indicate whether a file
is writeable instead of file permissions, but
don't actually enforce it.
Refuse to change attributes on the root
directory, because it is special in FAT
filesystems, but allow most other attribute
changes on directories.
Don't set the archive attribute on a directory
when its modification time is updated.
Windows and DOS don't set the archive attribute
in that scenario, so we are now bug-for-bug
compatible.
smbfs_node.c,
smbfs_vnops.c: Add support for UF_HIDDEN, UF_SYSTEM,
UF_READONLY and UF_ARCHIVE in SMBFS.
This is similar to changes that Apple has
made in their version of SMBFS (as of
smb-583.8, posted on opensource.apple.com),
but not quite the same.
We map SMB_FA_READONLY to UF_READONLY,
because UF_READONLY is intended to match
the semantics of the DOS readonly flag.
The MacOS X code maps both UF_IMMUTABLE
and SF_IMMUTABLE to SMB_FA_READONLY, but
the immutable flags have stronger meaning
than the DOS readonly bit.
stat.h: Add definitions for UF_SYSTEM, UF_SPARSE,
UF_OFFLINE, UF_REPARSE, UF_ARCHIVE, UF_READONLY
and UF_HIDDEN.
The definition of UF_HIDDEN is the same as
the MacOS X definition.
Add commented-out definitions of
UF_COMPRESSED and UF_TRACKED. They are
defined in MacOS X (as of 10.8.2), but we
do not implement them (yet).
ufs_vnops.c: Add support for getting and setting
UF_ARCHIVE, UF_HIDDEN, UF_OFFLINE, UF_READONLY,
UF_REPARSE, UF_SPARSE, and UF_SYSTEM in UFS.
Alphabetize the flags that are supported.
These new flags are only stored, UFS does
not take any action if the flag is set.
Sponsored by: Spectra Logic
Reviewed by: bde (earlier version)
2013-08-21 23:04:48 +00:00
|
|
|
if (np->n_dosattr & SMB_FA_HIDDEN)
|
|
|
|
va->va_flags |= UF_HIDDEN;
|
|
|
|
if (np->n_dosattr & SMB_FA_SYSTEM)
|
|
|
|
va->va_flags |= UF_SYSTEM;
|
|
|
|
/*
|
|
|
|
* We don't set the archive bit for directories.
|
|
|
|
*/
|
|
|
|
if ((vp->v_type != VDIR) && (np->n_dosattr & SMB_FA_ARCHIVE))
|
|
|
|
va->va_flags |= UF_ARCHIVE;
|
2008-09-20 19:49:15 +00:00
|
|
|
va->va_rdev = NODEV; /* device the special file represents */
|
2001-04-10 07:59:06 +00:00
|
|
|
va->va_bytes = va->va_size; /* bytes of disk space held by file */
|
|
|
|
va->va_filerev = 0; /* file modification number */
|
|
|
|
va->va_vaflags = 0; /* operations flags */
|
|
|
|
return 0;
|
|
|
|
}
|