Change VOP_READDIR's cookies argument to a **uint64_t
The cookies argument is only used by the NFS server. NFSv2 defines the cookie as 32 bits on the wire, but NFSv3 increased it to 64 bits. Our VOP_READDIR, however, has always defined it as u_long, which is 32 bits on some architectures. Change it to 64 bits on all architectures. This doesn't matter for any in-tree file systems, but it matters for some FUSE file systems that use 64-bit directory cookies. PR: 260375 Reviewed by: rmacklem Differential Revision: https://reviews.freebsd.org/D33404
This commit is contained in:
parent
32fbc5d824
commit
b214fcceac
@ -28,7 +28,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 30, 2020
|
||||
.Dd December 13, 2021
|
||||
.Dt VOP_READDIR 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -39,7 +39,7 @@
|
||||
.In sys/dirent.h
|
||||
.In sys/vnode.h
|
||||
.Ft int
|
||||
.Fn VOP_READDIR "struct vnode *vp" "struct uio *uio" "struct ucred *cred" "int *eofflag" "int *ncookies" "u_long **cookies"
|
||||
.Fn VOP_READDIR "struct vnode *vp" "struct uio *uio" "struct ucred *cred" "int *eofflag" "int *ncookies" "uint64_t **cookies"
|
||||
.Sh DESCRIPTION
|
||||
Read directory entries.
|
||||
.Bl -tag -width ncookies
|
||||
@ -92,7 +92,7 @@ Memory for the cookies should be allocated using:
|
||||
.Bd -literal
|
||||
...;
|
||||
*ncookies = number of entries read;
|
||||
*cookies = malloc(*ncookies * sizeof(u_long), M_TEMP, M_WAITOK);
|
||||
*cookies = malloc(*ncookies * sizeof(**cookies), M_TEMP, M_WAITOK);
|
||||
.Ed
|
||||
.Sh ERRORS
|
||||
.Bl -tag -width Er
|
||||
|
@ -1665,7 +1665,7 @@ zfs_rmdir(znode_t *dzp, const char *name, znode_t *cwd, cred_t *cr, int flags)
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
zfs_readdir(vnode_t *vp, zfs_uio_t *uio, cred_t *cr, int *eofp,
|
||||
int *ncookies, ulong_t **cookies)
|
||||
int *ncookies, uint64_t **cookies)
|
||||
{
|
||||
znode_t *zp = VTOZ(vp);
|
||||
iovec_t *iovp;
|
||||
@ -1687,7 +1687,7 @@ zfs_readdir(vnode_t *vp, zfs_uio_t *uio, cred_t *cr, int *eofp,
|
||||
boolean_t check_sysattrs;
|
||||
uint8_t type;
|
||||
int ncooks;
|
||||
ulong_t *cooks = NULL;
|
||||
uint64_t *cooks = NULL;
|
||||
int flags = 0;
|
||||
|
||||
ZFS_ENTER(zfsvfs);
|
||||
@ -1764,7 +1764,7 @@ zfs_readdir(vnode_t *vp, zfs_uio_t *uio, cred_t *cr, int *eofp,
|
||||
*/
|
||||
ncooks = zfs_uio_resid(uio) / (sizeof (struct dirent) -
|
||||
sizeof (((struct dirent *)NULL)->d_name) + 1);
|
||||
cooks = malloc(ncooks * sizeof (ulong_t), M_TEMP, M_WAITOK);
|
||||
cooks = malloc(ncooks * sizeof (*cooks), M_TEMP, M_WAITOK);
|
||||
*cookies = cooks;
|
||||
*ncookies = ncooks;
|
||||
}
|
||||
@ -4720,7 +4720,7 @@ struct vop_readdir_args {
|
||||
struct ucred *a_cred;
|
||||
int *a_eofflag;
|
||||
int *a_ncookies;
|
||||
ulong_t **a_cookies;
|
||||
uint64_t **a_cookies;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -367,7 +367,7 @@ struct isoreaddir {
|
||||
struct uio *uio;
|
||||
off_t uio_off;
|
||||
int eofflag;
|
||||
u_long *cookies;
|
||||
uint64_t *cookies;
|
||||
int ncookies;
|
||||
};
|
||||
|
||||
@ -464,7 +464,7 @@ cd9660_readdir(ap)
|
||||
struct ucred *a_cred;
|
||||
int *a_eofflag;
|
||||
int *a_ncookies;
|
||||
u_long **a_cookies;
|
||||
uint64_t **a_cookies;
|
||||
} */ *ap;
|
||||
{
|
||||
struct uio *uio = ap->a_uio;
|
||||
@ -481,7 +481,7 @@ cd9660_readdir(ap)
|
||||
int reclen;
|
||||
u_short namelen;
|
||||
u_int ncookies = 0;
|
||||
u_long *cookies = NULL;
|
||||
uint64_t *cookies = NULL;
|
||||
cd_ino_t ino;
|
||||
|
||||
dp = VTOI(vdp);
|
||||
@ -504,8 +504,7 @@ cd9660_readdir(ap)
|
||||
* Guess the number of cookies needed.
|
||||
*/
|
||||
ncookies = uio->uio_resid / 16;
|
||||
cookies = malloc(ncookies * sizeof(u_long),
|
||||
M_TEMP, M_WAITOK);
|
||||
cookies = malloc(ncookies * sizeof(*cookies), M_TEMP, M_WAITOK);
|
||||
idp->cookies = cookies;
|
||||
idp->ncookies = ncookies;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ ext2_readdir(struct vop_readdir_args *ap)
|
||||
struct buf *bp;
|
||||
struct inode *ip;
|
||||
struct ext2fs_direct_2 *dp, *edp;
|
||||
u_long *cookies;
|
||||
uint64_t *cookies;
|
||||
struct dirent dstdp;
|
||||
off_t offset, startoffset;
|
||||
size_t readcnt, skipcnt;
|
||||
|
@ -559,7 +559,7 @@ fuse_internal_readdir(struct vnode *vp,
|
||||
struct fuse_filehandle *fufh,
|
||||
struct fuse_iov *cookediov,
|
||||
int *ncookies,
|
||||
u_long *cookies)
|
||||
uint64_t *cookies)
|
||||
{
|
||||
int err = 0;
|
||||
struct fuse_dispatcher fdi;
|
||||
@ -625,7 +625,7 @@ fuse_internal_readdir_processdata(struct uio *uio,
|
||||
size_t bufsize,
|
||||
struct fuse_iov *cookediov,
|
||||
int *ncookies,
|
||||
u_long **cookiesp)
|
||||
uint64_t **cookiesp)
|
||||
{
|
||||
int err = 0;
|
||||
int oreclen;
|
||||
@ -633,7 +633,7 @@ fuse_internal_readdir_processdata(struct uio *uio,
|
||||
|
||||
struct dirent *de;
|
||||
struct fuse_dirent *fudge;
|
||||
u_long *cookies;
|
||||
uint64_t *cookies;
|
||||
|
||||
cookies = *cookiesp;
|
||||
if (bufsize < FUSE_NAME_OFFSET)
|
||||
|
@ -252,10 +252,10 @@ struct pseudo_dirent {
|
||||
};
|
||||
int fuse_internal_readdir(struct vnode *vp, struct uio *uio, off_t startoff,
|
||||
struct fuse_filehandle *fufh, struct fuse_iov *cookediov, int *ncookies,
|
||||
u_long *cookies);
|
||||
uint64_t *cookies);
|
||||
int fuse_internal_readdir_processdata(struct uio *uio, off_t startoff,
|
||||
int *fnd_start, size_t reqsize, void *buf, size_t bufsize,
|
||||
struct fuse_iov *cookediov, int *ncookies, u_long **cookiesp);
|
||||
struct fuse_iov *cookediov, int *ncookies, uint64_t **cookiesp);
|
||||
|
||||
/* remove */
|
||||
|
||||
|
@ -1730,7 +1730,7 @@ fuse_vnop_read(struct vop_read_args *ap)
|
||||
struct ucred *a_cred;
|
||||
int *a_eofflag;
|
||||
int *a_ncookies;
|
||||
u_long **a_cookies;
|
||||
uint64_t **a_cookies;
|
||||
};
|
||||
*/
|
||||
static int
|
||||
@ -1742,7 +1742,7 @@ fuse_vnop_readdir(struct vop_readdir_args *ap)
|
||||
struct fuse_filehandle *fufh = NULL;
|
||||
struct fuse_iov cookediov;
|
||||
int err = 0;
|
||||
u_long *cookies;
|
||||
uint64_t *cookies;
|
||||
off_t startoff;
|
||||
ssize_t tresid;
|
||||
int ncookies;
|
||||
|
@ -1517,7 +1517,7 @@ msdosfs_readdir(struct vop_readdir_args *ap)
|
||||
struct direntry *dentp;
|
||||
struct dirent dirbuf;
|
||||
struct uio *uio = ap->a_uio;
|
||||
u_long *cookies = NULL;
|
||||
uint64_t *cookies = NULL;
|
||||
int ncookies = 0;
|
||||
off_t offset, off;
|
||||
int chksum = -1;
|
||||
@ -1553,7 +1553,7 @@ msdosfs_readdir(struct vop_readdir_args *ap)
|
||||
|
||||
if (ap->a_ncookies) {
|
||||
ncookies = uio->uio_resid / 16;
|
||||
cookies = malloc(ncookies * sizeof(u_long), M_TEMP,
|
||||
cookies = malloc(ncookies * sizeof(*cookies), M_TEMP,
|
||||
M_WAITOK);
|
||||
*ap->a_cookies = cookies;
|
||||
*ap->a_ncookies = ncookies;
|
||||
|
@ -2047,7 +2047,7 @@ nfsrvd_readdir(struct nfsrv_descript *nd, int isdgram,
|
||||
int nlen, error = 0, getret = 1;
|
||||
int siz, cnt, fullsiz, eofflag, ncookies;
|
||||
u_int64_t off, toff, verf __unused;
|
||||
u_long *cookies = NULL, *cookiep;
|
||||
uint64_t *cookies = NULL, *cookiep;
|
||||
struct uio io;
|
||||
struct iovec iv;
|
||||
int is_ufs;
|
||||
@ -2309,7 +2309,7 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdgram,
|
||||
int siz, cnt, fullsiz, eofflag, ncookies, entrycnt;
|
||||
caddr_t bpos0, bpos1;
|
||||
u_int64_t off, toff, verf __unused;
|
||||
u_long *cookies = NULL, *cookiep;
|
||||
uint64_t *cookies = NULL, *cookiep;
|
||||
nfsattrbit_t attrbits, rderrbits, savbits;
|
||||
struct uio io;
|
||||
struct iovec iv;
|
||||
|
@ -831,7 +831,7 @@ smbfs_readdir(ap)
|
||||
struct uio *a_uio;
|
||||
struct ucred *a_cred;
|
||||
int *a_eofflag;
|
||||
u_long *a_cookies;
|
||||
uint64_t *a_cookies;
|
||||
int a_ncookies;
|
||||
} */ *ap;
|
||||
{
|
||||
|
@ -455,7 +455,7 @@ struct tmpfs_dirent * tmpfs_dir_lookup(struct tmpfs_node *node,
|
||||
struct tmpfs_node *f,
|
||||
struct componentname *cnp);
|
||||
int tmpfs_dir_getdents(struct tmpfs_mount *, struct tmpfs_node *,
|
||||
struct uio *, int, u_long *, int *);
|
||||
struct uio *, int, uint64_t *, int *);
|
||||
int tmpfs_dir_whiteout_add(struct vnode *, struct componentname *);
|
||||
void tmpfs_dir_whiteout_remove(struct vnode *, struct componentname *);
|
||||
int tmpfs_reg_resize(struct vnode *, off_t, boolean_t);
|
||||
|
@ -1527,7 +1527,7 @@ tmpfs_dir_getdotdotdent(struct tmpfs_mount *tm, struct tmpfs_node *node,
|
||||
*/
|
||||
int
|
||||
tmpfs_dir_getdents(struct tmpfs_mount *tm, struct tmpfs_node *node,
|
||||
struct uio *uio, int maxcookies, u_long *cookies, int *ncookies)
|
||||
struct uio *uio, int maxcookies, uint64_t *cookies, int *ncookies)
|
||||
{
|
||||
struct tmpfs_dir_cursor dc;
|
||||
struct tmpfs_dirent *de, *nde;
|
||||
|
@ -1389,7 +1389,7 @@ tmpfs_readdir(struct vop_readdir_args *va)
|
||||
struct uio *uio;
|
||||
struct tmpfs_mount *tm;
|
||||
struct tmpfs_node *node;
|
||||
u_long **cookies;
|
||||
uint64_t **cookies;
|
||||
int *eofflag, *ncookies;
|
||||
ssize_t startresid;
|
||||
int error, maxcookies;
|
||||
|
@ -607,7 +607,7 @@ udf_cmpname(char *cs0string, char *cmpname, int cs0len, int cmplen, struct udf_m
|
||||
|
||||
struct udf_uiodir {
|
||||
struct dirent *dirent;
|
||||
u_long *cookies;
|
||||
uint64_t *cookies;
|
||||
int ncookies;
|
||||
int acookies;
|
||||
int eofflag;
|
||||
@ -787,7 +787,7 @@ udf_readdir(struct vop_readdir_args *a)
|
||||
struct fileid_desc *fid;
|
||||
struct udf_uiodir uiodir;
|
||||
struct udf_dirstream *ds;
|
||||
u_long *cookies = NULL;
|
||||
uint64_t *cookies = NULL;
|
||||
int ncookies;
|
||||
int error = 0;
|
||||
|
||||
@ -804,8 +804,7 @@ udf_readdir(struct vop_readdir_args *a)
|
||||
* it left off.
|
||||
*/
|
||||
ncookies = uio->uio_resid / 8;
|
||||
cookies = malloc(sizeof(u_long) * ncookies,
|
||||
M_TEMP, M_WAITOK);
|
||||
cookies = malloc(sizeof(*cookies) * ncookies, M_TEMP, M_WAITOK);
|
||||
if (cookies == NULL)
|
||||
return (ENOMEM);
|
||||
uiodir.ncookies = ncookies;
|
||||
|
@ -1509,7 +1509,7 @@ unionfs_readdir(struct vop_readdir_args *ap)
|
||||
struct thread *td;
|
||||
struct vattr va;
|
||||
|
||||
u_long *cookies_bk;
|
||||
uint64_t *cookies_bk;
|
||||
int error;
|
||||
int eofflag;
|
||||
int locked;
|
||||
@ -1660,17 +1660,17 @@ unionfs_readdir(struct vop_readdir_args *ap)
|
||||
if (cookies_bk != NULL) {
|
||||
/* merge cookies */
|
||||
int size;
|
||||
u_long *newcookies, *pos;
|
||||
uint64_t *newcookies, *pos;
|
||||
|
||||
size = *(ap->a_ncookies) + ncookies_bk;
|
||||
newcookies = (u_long *) malloc(size * sizeof(u_long),
|
||||
newcookies = (uint64_t *) malloc(size * sizeof(*newcookies),
|
||||
M_TEMP, M_WAITOK);
|
||||
pos = newcookies;
|
||||
|
||||
memcpy(pos, cookies_bk, ncookies_bk * sizeof(u_long));
|
||||
memcpy(pos, cookies_bk, ncookies_bk * sizeof(*newcookies));
|
||||
pos += ncookies_bk;
|
||||
memcpy(pos, *(ap->a_cookies),
|
||||
*(ap->a_ncookies) * sizeof(u_long));
|
||||
*(ap->a_ncookies) * sizeof(*newcookies));
|
||||
free(cookies_bk, M_TEMP);
|
||||
free(*(ap->a_cookies), M_TEMP);
|
||||
*(ap->a_ncookies) = size;
|
||||
|
@ -1369,7 +1369,7 @@ struct vop_readdir_args {
|
||||
struct ucred *a_cred;
|
||||
int *a_eofflag;
|
||||
int *a_ncookies;
|
||||
u_long **a_cookies;
|
||||
uint64_t **a_cookies;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -6419,7 +6419,7 @@ vfs_read_dirent(struct vop_readdir_args *ap, struct dirent *dp, off_t off)
|
||||
("NULL ap->a_cookies value with non-NULL ap->a_ncookies!"));
|
||||
|
||||
*ap->a_cookies = realloc(*ap->a_cookies,
|
||||
(*ap->a_ncookies + 1) * sizeof(u_long), M_TEMP, M_WAITOK | M_ZERO);
|
||||
(*ap->a_ncookies + 1) * sizeof(uint64_t), M_TEMP, M_WAITOK | M_ZERO);
|
||||
(*ap->a_cookies)[*ap->a_ncookies] = off;
|
||||
*ap->a_ncookies += 1;
|
||||
return (0);
|
||||
|
@ -392,7 +392,7 @@ vop_readdir {
|
||||
IN struct ucred *cred;
|
||||
INOUT int *eofflag;
|
||||
OUT int *ncookies;
|
||||
INOUT u_long **cookies;
|
||||
INOUT uint64_t **cookies;
|
||||
};
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@
|
||||
* cannot include sys/param.h and should only be updated here.
|
||||
*/
|
||||
#undef __FreeBSD_version
|
||||
#define __FreeBSD_version 1400044
|
||||
#define __FreeBSD_version 1400045
|
||||
|
||||
/*
|
||||
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
|
||||
|
@ -2336,7 +2336,7 @@ ufs_readdir(ap)
|
||||
struct ucred *a_cred;
|
||||
int *a_eofflag;
|
||||
int *a_ncookies;
|
||||
u_long **a_cookies;
|
||||
uint64_t **a_cookies;
|
||||
} */ *ap;
|
||||
{
|
||||
struct vnode *vp = ap->a_vp;
|
||||
@ -2344,7 +2344,7 @@ ufs_readdir(ap)
|
||||
struct buf *bp;
|
||||
struct inode *ip;
|
||||
struct direct *dp, *edp;
|
||||
u_long *cookies;
|
||||
uint64_t *cookies;
|
||||
struct dirent dstdp;
|
||||
off_t offset, startoffset;
|
||||
size_t readcnt, skipcnt;
|
||||
|
Loading…
Reference in New Issue
Block a user