stat(2): add st_filerev

Reviewed by:	asomers, markj, olce, rmacklem
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D48452
This commit is contained in:
Konstantin Belousov 2025-01-13 23:14:04 +02:00
parent 661ca921e8
commit b4663a8d11
9 changed files with 13 additions and 2 deletions

View file

@ -240,7 +240,8 @@ struct stat32 {
uint32_t st_blksize;
uint32_t st_flags;
uint64_t st_gen;
uint64_t st_spare[10];
uint64_t st_filerev;
uint64_t st_spare[9];
};
struct freebsd11_stat32 {
uint32_t st_dev;

View file

@ -2251,6 +2251,7 @@ copy_stat(struct stat *in, struct stat32 *out)
CP(*in, *out, st_blksize);
CP(*in, *out, st_flags);
CP(*in, *out, st_gen);
CP(*in, *out, st_filerev);
TS_CP(*in, *out, st_birthtim);
out->st_padding0 = 0;
out->st_padding1 = 0;

View file

@ -476,6 +476,7 @@ tmpfs_stat(struct vop_stat_args *v)
sb->st_blksize = PAGE_SIZE;
sb->st_flags = node->tn_flags;
sb->st_gen = node->tn_gen;
sb->st_filerev = 0;
if (vp->v_type == VREG) {
#ifdef __ILP32__
vm_object_t obj = node->tn_reg.tn_aobj;

View file

@ -1620,6 +1620,7 @@ kern_fstat(struct thread *td, int fd, struct stat *sbp)
AUDIT_ARG_FILE(td->td_proc, fp);
sbp->st_filerev = 0;
error = fo_stat(fp, sbp, td->td_ucred);
fdrop(fp, td);
#ifdef __STAT_TIME_T_EXT

View file

@ -1511,6 +1511,7 @@ vop_stdstat(struct vop_stat_args *a)
vap->va_fsid = VNOVAL;
vap->va_gen = 0;
vap->va_rdev = NODEV;
vap->va_filerev = 0;
error = VOP_GETATTR(vp, vap, a->a_active_cred);
if (error)
@ -1587,6 +1588,7 @@ vop_stdstat(struct vop_stat_args *a)
sb->st_flags = vap->va_flags;
sb->st_blocks = vap->va_bytes / S_BLKSIZE;
sb->st_gen = vap->va_gen;
sb->st_filerev = vap->va_filerev;
out:
return (vop_stat_helper_post(a, error));
}

View file

@ -1200,6 +1200,7 @@ vattr_null(struct vattr *vap)
vap->va_flags = VNOVAL;
vap->va_gen = VNOVAL;
vap->va_vaflags = 0;
vap->va_filerev = VNOVAL;
}
/*

View file

@ -185,7 +185,8 @@ struct stat {
blksize_t st_blksize; /* optimal blocksize for I/O */
fflags_t st_flags; /* user defined flags for file */
__uint64_t st_gen; /* file generation number */
__uint64_t st_spare[10];
__uint64_t st_filerev; /* file revision, incr on changes */
__uint64_t st_spare[9];
};
#ifdef _KERNEL

View file

@ -989,6 +989,7 @@ void vop_rename_fail(struct vop_rename_args *ap);
ap->a_sb->st_padding0 = 0; \
ap->a_sb->st_padding1 = 0; \
bzero(_ap->a_sb->st_spare, sizeof(_ap->a_sb->st_spare)); \
ap->a_sb->st_filerev = 0; \
} \
_error; \
})

View file

@ -549,6 +549,7 @@ ufs_stat(struct vop_stat_args *ap)
sb->st_birthtim.tv_sec = -1;
sb->st_birthtim.tv_nsec = 0;
sb->st_blocks = dbtob((uint64_t)ip->i_din1->di_blocks) / S_BLKSIZE;
sb->st_filerev = ip->i_din1->di_modrev;
} else {
sb->st_rdev = ip->i_din2->di_rdev;
sb->st_size = ip->i_din2->di_size;
@ -559,6 +560,7 @@ ufs_stat(struct vop_stat_args *ap)
sb->st_birthtim.tv_sec = ip->i_din2->di_birthtime;
sb->st_birthtim.tv_nsec = ip->i_din2->di_birthnsec;
sb->st_blocks = dbtob((uint64_t)ip->i_din2->di_blocks) / S_BLKSIZE;
sb->st_filerev = ip->i_din2->di_modrev;
}
sb->st_blksize = max(PAGE_SIZE, vp->v_mount->mnt_stat.f_iosize);