svn commit: r187534 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
dev/cxgb fs/devfs fs/fdescfs fs/hpfs fs/msdosfs fs/ntfs
fs/portalfs fs/pseudofs fs/smbfs fs/tmpfs fs/udf
gnu/fs/xfs/FreeBSD kern ...
Konstantin Belousov
kib at FreeBSD.org
Wed Jan 21 07:51:17 PST 2009
Author: kib
Date: Wed Jan 21 15:51:15 2009
New Revision: 187534
URL: http://svn.freebsd.org/changeset/base/187534
Log:
MFC r183211:
Initialize birthtime fields in vn_stat() to prevent stat(2) from
returning uninitialized birthtime. Most file systems don't initialize
birthtime properly in their VOP_GETTATTR().
MFC r183212:
Initialize va_flags and va_filerev properly in VOP_GETATTR(). Don't
initialize va_vaflags and va_spare because they are not part of the
VOP_GETATTR() API. Also don't initialize birthtime to ctime or zero.
MFC rr183213:
Initialize va_rdev to NODEV and va_fsid to VNOVAL before the
VOP_GETATTR() call in vn_stat(). Thus if a file system doesn't
initialize those fields in VOP_GETATTR() they will have a sane default
value.
MFC r183214:
Initialize va_rdev to NODEV instead of 0 or VNOVAL in VOP_GETATTR().
NODEV is more appropriate when va_rdev doesn't have a meaningful value.
MFC r183215:
fdescfs, devfs, mqueuefs, nfs, portalfs, pseudofs, tmpfs and xfs
initialize the vattr structure in VOP_GETATTR() with VATTR_NULL(),
vattr_null() or by zeroing it. Remove these to allow preinitialization
of fields work in vn_stat(). This is needed to get birthtime initialized
correctly.
Modified:
stable/7/sys/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
stable/7/sys/dev/ath/ath_hal/ (props changed)
stable/7/sys/dev/cxgb/ (props changed)
stable/7/sys/fs/devfs/devfs_vnops.c
stable/7/sys/fs/fdescfs/fdesc_vnops.c
stable/7/sys/fs/hpfs/hpfs_vnops.c
stable/7/sys/fs/msdosfs/msdosfs_vnops.c
stable/7/sys/fs/ntfs/ntfs_vnops.c
stable/7/sys/fs/portalfs/portal_vnops.c
stable/7/sys/fs/pseudofs/pseudofs_vnops.c
stable/7/sys/fs/smbfs/smbfs_node.c
stable/7/sys/fs/tmpfs/tmpfs_vnops.c
stable/7/sys/fs/udf/udf_vnops.c
stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c
stable/7/sys/kern/uipc_mqueue.c
stable/7/sys/kern/vfs_vnops.c
stable/7/sys/nfsclient/nfs_vnops.c
stable/7/sys/ufs/ufs/ufs_vnops.c
Modified: stable/7/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- stable/7/sys/fs/devfs/devfs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/devfs/devfs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -507,8 +507,6 @@ devfs_getattr(struct vop_getattr_args *a
KASSERT(de != NULL,
("Null dir dirent in devfs_getattr vp=%p", vp));
}
- bzero((caddr_t) vap, sizeof(*vap));
- vattr_null(vap);
vap->va_uid = de->de_uid;
vap->va_gid = de->de_gid;
vap->va_mode = de->de_mode;
@@ -551,6 +549,7 @@ devfs_getattr(struct vop_getattr_args *a
}
vap->va_gen = 0;
vap->va_flags = 0;
+ vap->va_filerev = 0;
vap->va_nlink = de->de_links;
vap->va_fileid = de->de_inode;
Modified: stable/7/sys/fs/fdescfs/fdesc_vnops.c
==============================================================================
--- stable/7/sys/fs/fdescfs/fdesc_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/fdescfs/fdesc_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -391,8 +391,6 @@ fdesc_getattr(ap)
switch (VTOFDESC(vp)->fd_type) {
case Froot:
- VATTR_NULL(vap);
-
vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
vap->va_type = VDIR;
vap->va_nlink = 2;
@@ -407,8 +405,9 @@ fdesc_getattr(ap)
vap->va_ctime = vap->va_mtime;
vap->va_gen = 0;
vap->va_flags = 0;
- vap->va_rdev = 0;
+ vap->va_rdev = NODEV;
vap->va_bytes = 0;
+ vap->va_filerev = 0;
break;
case Fdesc:
@@ -421,7 +420,6 @@ fdesc_getattr(ap)
error = fo_stat(fp, &stb, ap->a_td->td_ucred, ap->a_td);
fdrop(fp, ap->a_td);
if (error == 0) {
- VATTR_NULL(vap);
vap->va_type = IFTOVT(stb.st_mode);
vap->va_mode = stb.st_mode;
#define FDRX (VREAD|VEXEC)
@@ -456,6 +454,8 @@ fdesc_getattr(ap)
vap->va_ctime = stb.st_ctimespec;
vap->va_uid = stb.st_uid;
vap->va_gid = stb.st_gid;
+ vap->va_gen = 0;
+ vap->va_filerev = 0;
}
break;
Modified: stable/7/sys/fs/hpfs/hpfs_vnops.c
==============================================================================
--- stable/7/sys/fs/hpfs/hpfs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/hpfs/hpfs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -425,7 +425,7 @@ hpfs_getattr(ap)
vap->va_nlink = 1;
vap->va_uid = hp->h_uid;
vap->va_gid = hp->h_gid;
- vap->va_rdev = 0; /* XXX UNODEV ? */
+ vap->va_rdev = NODEV;
vap->va_size = hp->h_fn.fn_size;
vap->va_bytes = ((hp->h_fn.fn_size + DEV_BSIZE-1) & ~(DEV_BSIZE-1)) +
DEV_BSIZE;
Modified: stable/7/sys/fs/msdosfs/msdosfs_vnops.c
==============================================================================
--- stable/7/sys/fs/msdosfs/msdosfs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/msdosfs/msdosfs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -335,7 +335,7 @@ msdosfs_getattr(ap)
vap->va_uid = pmp->pm_uid;
vap->va_gid = pmp->pm_gid;
vap->va_nlink = 1;
- vap->va_rdev = 0;
+ vap->va_rdev = NODEV;
vap->va_size = dep->de_FileSize;
fattime2timespec(dep->de_MDate, dep->de_MTime, 0, 0, &vap->va_mtime);
vap->va_ctime = vap->va_mtime;
Modified: stable/7/sys/fs/ntfs/ntfs_vnops.c
==============================================================================
--- stable/7/sys/fs/ntfs/ntfs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/ntfs/ntfs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -191,7 +191,7 @@ ntfs_getattr(ap)
vap->va_nlink = (ip->i_nlink || ip->i_flag & IN_LOADED ? ip->i_nlink : 1);
vap->va_uid = ip->i_mp->ntm_uid;
vap->va_gid = ip->i_mp->ntm_gid;
- vap->va_rdev = 0; /* XXX UNODEV ? */
+ vap->va_rdev = NODEV;
vap->va_size = fp->f_size;
vap->va_bytes = fp->f_allocated;
vap->va_atime = ntfs_nttimetounix(fp->f_times.t_access);
Modified: stable/7/sys/fs/portalfs/portal_vnops.c
==============================================================================
--- stable/7/sys/fs/portalfs/portal_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/portalfs/portal_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -453,8 +453,6 @@ portal_getattr(ap)
struct vnode *vp = ap->a_vp;
struct vattr *vap = ap->a_vap;
- bzero(vap, sizeof(*vap));
- vattr_null(vap);
vap->va_uid = 0;
vap->va_gid = 0;
vap->va_size = DEV_BSIZE;
@@ -464,9 +462,10 @@ portal_getattr(ap)
vap->va_ctime = vap->va_mtime;
vap->va_gen = 0;
vap->va_flags = 0;
- vap->va_rdev = 0;
+ vap->va_rdev = NODEV;
/* vap->va_qbytes = 0; */
vap->va_bytes = 0;
+ vap->va_filerev = 0;
/* vap->va_qsize = 0; */
if (vp->v_vflag & VV_ROOT) {
vap->va_type = VDIR;
Modified: stable/7/sys/fs/pseudofs/pseudofs_vnops.c
==============================================================================
--- stable/7/sys/fs/pseudofs/pseudofs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/pseudofs/pseudofs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -191,12 +191,12 @@ pfs_getattr(struct vop_getattr_args *va)
if (!pfs_visible(curthread, pn, pvd->pvd_pid, &proc))
PFS_RETURN (ENOENT);
- VATTR_NULL(vap);
vap->va_type = vn->v_type;
vap->va_fileid = pn_fileno(pn, pvd->pvd_pid);
vap->va_flags = 0;
vap->va_blocksize = PAGE_SIZE;
vap->va_bytes = vap->va_size = 0;
+ vap->va_filerev = 0;
vap->va_fsid = vn->v_mount->mnt_stat.f_fsid.val[0];
vap->va_nlink = 1;
nanotime(&vap->va_ctime);
Modified: stable/7/sys/fs/smbfs/smbfs_node.c
==============================================================================
--- stable/7/sys/fs/smbfs/smbfs_node.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/smbfs/smbfs_node.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -438,7 +438,7 @@ smbfs_attr_cachelookup(struct vnode *vp,
va->va_atime = va->va_ctime = va->va_mtime; /* time file changed */
va->va_gen = VNOVAL; /* generation number of file */
va->va_flags = 0; /* flags defined for file */
- va->va_rdev = VNOVAL; /* device the special file represents */
+ va->va_rdev = NODEV; /* device the special file represents */
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 */
Modified: stable/7/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- stable/7/sys/fs/tmpfs/tmpfs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/tmpfs/tmpfs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -344,8 +344,6 @@ tmpfs_getattr(struct vop_getattr_args *v
node = VP_TO_TMPFS_NODE(vp);
- VATTR_NULL(vap);
-
tmpfs_update(vp);
vap->va_type = vp->v_type;
@@ -364,11 +362,9 @@ tmpfs_getattr(struct vop_getattr_args *v
vap->va_gen = node->tn_gen;
vap->va_flags = node->tn_flags;
vap->va_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ?
- node->tn_rdev : VNOVAL;
+ node->tn_rdev : NODEV;
vap->va_bytes = round_page(node->tn_size);
- vap->va_filerev = VNOVAL;
- vap->va_vaflags = 0;
- vap->va_spare = VNOVAL; /* XXX */
+ vap->va_filerev = 0;
return 0;
}
Modified: stable/7/sys/fs/udf/udf_vnops.c
==============================================================================
--- stable/7/sys/fs/udf/udf_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/fs/udf/udf_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -279,7 +279,7 @@ udf_getattr(struct vop_getattr_args *a)
udf_timetotimespec(&fentry->atime, &vap->va_atime);
udf_timetotimespec(&fentry->mtime, &vap->va_mtime);
vap->va_ctime = vap->va_mtime; /* XXX Stored as an Extended Attribute */
- vap->va_rdev = 0; /* XXX */
+ vap->va_rdev = NODEV;
if (vp->v_type & VDIR) {
/*
* Directories that are recorded within their ICB will show
Modified: stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c
==============================================================================
--- stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -241,7 +241,6 @@ _xfs_getattr(
/* extract the xfs vnode from the private data */
//xfs_vnode_t *xvp = (xfs_vnode_t *)vp->v_data;
- VATTR_NULL(vap);
memset(&va,0,sizeof(xfs_vattr_t));
va.va_mask = XFS_AT_STAT|XFS_AT_GENCOUNT|XFS_AT_XFLAGS;
@@ -274,15 +273,9 @@ _xfs_getattr(
/*
* Fields with no direct equivalent in XFS
- * leave initialized by VATTR_NULL
*/
-#if 0
vap->va_filerev = 0;
- vap->va_birthtime = va.va_ctime;
- vap->va_vaflags = 0;
vap->va_flags = 0;
- vap->va_spare = 0;
-#endif
return (0);
}
Modified: stable/7/sys/kern/uipc_mqueue.c
==============================================================================
--- stable/7/sys/kern/uipc_mqueue.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/kern/uipc_mqueue.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -1133,7 +1133,6 @@ mqfs_getattr(struct vop_getattr_args *ap
struct vattr *vap = ap->a_vap;
int error = 0;
- VATTR_NULL(vap);
vap->va_type = vp->v_type;
vap->va_mode = pn->mn_mode;
vap->va_nlink = 1;
@@ -1150,10 +1149,9 @@ mqfs_getattr(struct vop_getattr_args *ap
vap->va_birthtime = pn->mn_birth;
vap->va_gen = 0;
vap->va_flags = 0;
- vap->va_rdev = 0;
+ vap->va_rdev = NODEV;
vap->va_bytes = 0;
vap->va_filerev = 0;
- vap->va_vaflags = 0;
return (error);
}
Modified: stable/7/sys/kern/vfs_vnops.c
==============================================================================
--- stable/7/sys/kern/vfs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/kern/vfs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -641,6 +641,17 @@ vn_stat(vp, sb, active_cred, file_cred,
#endif
vap = &vattr;
+
+ /*
+ * Initialize defaults for new and unusual fields, so that file
+ * systems which don't support these fields don't need to know
+ * about them.
+ */
+ vap->va_birthtime.tv_sec = -1;
+ vap->va_birthtime.tv_nsec = 0;
+ vap->va_fsid = VNOVAL;
+ vap->va_rdev = NODEV;
+
error = VOP_GETATTR(vp, vap, active_cred, td);
if (error)
return (error);
Modified: stable/7/sys/nfsclient/nfs_vnops.c
==============================================================================
--- stable/7/sys/nfsclient/nfs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/nfsclient/nfs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -631,6 +631,8 @@ nfs_getattr(struct vop_getattr_args *ap)
{
struct vnode *vp = ap->a_vp;
struct nfsnode *np = VTONFS(vp);
+ struct vattr *vap = ap->a_vap;
+ struct vattr vattr;
caddr_t bpos, dpos;
int error = 0;
struct mbuf *mreq, *mrep, *md, *mb;
@@ -646,12 +648,12 @@ nfs_getattr(struct vop_getattr_args *ap)
/*
* First look in the cache.
*/
- if (nfs_getattrcache(vp, ap->a_vap) == 0)
+ if (nfs_getattrcache(vp, &vattr) == 0)
goto nfsmout;
if (v3 && nfsaccess_cache_timeout > 0) {
nfsstats.accesscache_misses++;
nfs3_access_otw(vp, NFSV3ACCESS_ALL, ap->a_td, ap->a_cred);
- if (nfs_getattrcache(vp, ap->a_vap) == 0)
+ if (nfs_getattrcache(vp, &vattr) == 0)
goto nfsmout;
}
nfsstats.rpccnt[NFSPROC_GETATTR]++;
@@ -661,10 +663,28 @@ nfs_getattr(struct vop_getattr_args *ap)
nfsm_fhtom(vp, v3);
nfsm_request(vp, NFSPROC_GETATTR, ap->a_td, ap->a_cred);
if (!error) {
- nfsm_loadattr(vp, ap->a_vap);
+ nfsm_loadattr(vp, &vattr);
}
m_freem(mrep);
nfsmout:
+ vap->va_type = vattr.va_type;
+ vap->va_mode = vattr.va_mode;
+ vap->va_nlink = vattr.va_nlink;
+ vap->va_uid = vattr.va_uid;
+ vap->va_gid = vattr.va_gid;
+ vap->va_fsid = vattr.va_fsid;
+ vap->va_fileid = vattr.va_fileid;
+ vap->va_size = vattr.va_size;
+ vap->va_blocksize = vattr.va_blocksize;
+ vap->va_atime = vattr.va_atime;
+ vap->va_mtime = vattr.va_mtime;
+ vap->va_ctime = vattr.va_ctime;
+ vap->va_gen = vattr.va_gen;
+ vap->va_flags = vattr.va_flags;
+ vap->va_rdev = vattr.va_rdev;
+ vap->va_bytes = vattr.va_bytes;
+ vap->va_filerev = vattr.va_filerev;
+
return (error);
}
Modified: stable/7/sys/ufs/ufs/ufs_vnops.c
==============================================================================
--- stable/7/sys/ufs/ufs/ufs_vnops.c Wed Jan 21 15:25:00 2009 (r187533)
+++ stable/7/sys/ufs/ufs/ufs_vnops.c Wed Jan 21 15:51:15 2009 (r187534)
@@ -445,8 +445,6 @@ ufs_getattr(ap)
vap->va_mtime.tv_nsec = ip->i_din1->di_mtimensec;
vap->va_ctime.tv_sec = ip->i_din1->di_ctime;
vap->va_ctime.tv_nsec = ip->i_din1->di_ctimensec;
- vap->va_birthtime.tv_sec = 0;
- vap->va_birthtime.tv_nsec = 0;
vap->va_bytes = dbtob((u_quad_t)ip->i_din1->di_blocks);
} else {
vap->va_rdev = ip->i_din2->di_rdev;
More information about the svn-src-all
mailing list