msdosfs: use mem{cpy,move,set} instead of bcopy,bzero

This somewhat simplifies use of msdosfs code in userland (for makefs),
reduces diffs with NetBSD and is standard C as of C89.

Reviewed by:	imp
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D11014
This commit is contained in:
Ed Maste 2017-06-02 18:39:53 +00:00
parent a59a14773a
commit 6a1c2e1fce
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=319507
5 changed files with 17 additions and 17 deletions

View File

@ -179,7 +179,7 @@ struct denode {
#define DE_INTERNALIZE32(dep, dp) \
((dep)->de_StartCluster |= getushort((dp)->deHighClust) << 16)
#define DE_INTERNALIZE(dep, dp) \
(bcopy((dp)->deName, (dep)->de_Name, 11), \
(memcpy((dep)->de_Name, (dp)->deName, 11), \
(dep)->de_Attributes = (dp)->deAttributes, \
(dep)->de_LowerCase = (dp)->deLowerCase, \
(dep)->de_CHun = (dp)->deCHundredth, \
@ -193,7 +193,7 @@ struct denode {
(FAT32((dep)->de_pmp) ? DE_INTERNALIZE32((dep), (dp)) : 0))
#define DE_EXTERNALIZE(dp, dep) \
(bcopy((dep)->de_Name, (dp)->deName, 11), \
(memcpy((dp)->deName, (dep)->de_Name, 11), \
(dp)->deAttributes = (dep)->de_Attributes, \
(dp)->deLowerCase = (dep)->de_LowerCase, \
(dp)->deCHundredth = (dep)->de_CHun, \

View File

@ -536,7 +536,7 @@ unix2winfn(const u_char *un, size_t unlen, struct winentry *wep, int cnt,
/*
* Initialize winentry to some useful default
*/
for (wcp = (uint8_t *)wep, i = sizeof(*wep); --i >= 0; *wcp++ = 0xff);
memset(wep, 0xff, sizeof(*wep));
wep->weCnt = cnt;
wep->weAttributes = ATTR_WIN95;
wep->weReserved1 = 0;
@ -1043,11 +1043,11 @@ mbnambuf_write(struct mbnambuf *nbp, char *name, int id)
sizeof(nbp->nb_buf))
return (ENAMETOOLONG);
bcopy(slot + WIN_CHARS, slot + count, nbp->nb_len);
memmove(slot + count, slot + WIN_CHARS, nbp->nb_len);
}
/* Copy in the substring to its slot and update length so far. */
bcopy(name, slot, count);
memcpy(slot, name, count);
nbp->nb_len = newlen;
nbp->nb_last_id = id;
@ -1069,7 +1069,7 @@ mbnambuf_flush(struct mbnambuf *nbp, struct dirent *dp)
mbnambuf_init(nbp);
return (NULL);
}
bcopy(&nbp->nb_buf[0], dp->d_name, nbp->nb_len);
memcpy(dp->d_name, &nbp->nb_buf[0], nbp->nb_len);
dp->d_name[nbp->nb_len] = '\0';
dp->d_namlen = nbp->nb_len;

View File

@ -410,7 +410,7 @@ detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred)
#endif
return (error);
}
bzero(bp->b_data + boff, pmp->pm_bpcluster - boff);
memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff);
if (flags & IO_SYNC)
bwrite(bp);
else

View File

@ -335,7 +335,7 @@ updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn)
/* getblk() never fails */
bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount,
0, 0, 0);
bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
memcpy(bpn->b_data, bp->b_data, bp->b_bcount);
/* Force the clean bit on in the other copies. */
if (cleanfat == 16)
((uint8_t *)bpn->b_data)[3] |= 0x80;

View File

@ -165,7 +165,7 @@ msdosfs_create(struct vop_create_args *ap)
if ((cnp->cn_flags & HASBUF) == 0)
panic("msdosfs_create: no name");
#endif
bzero(&ndirent, sizeof(ndirent));
memset(&ndirent, 0, sizeof(ndirent));
error = uniqdosname(pdep, cnp, ndirent.de_Name);
if (error)
goto bad;
@ -1156,13 +1156,13 @@ msdosfs_rename(struct vop_rename_args *ap)
* we moved a directory, then update its .. entry to point
* to the new parent directory.
*/
bcopy(ip->de_Name, oldname, 11);
bcopy(toname, ip->de_Name, 11); /* update denode */
memcpy(oldname, ip->de_Name, 11);
memcpy(ip->de_Name, toname, 11); /* update denode */
dp->de_fndoffset = to_diroffset;
dp->de_fndcnt = to_count;
error = createde(ip, dp, (struct denode **)0, tcnp);
if (error) {
bcopy(oldname, ip->de_Name, 11);
memcpy(ip->de_Name, oldname, 11);
if (newparent)
VOP_UNLOCK(fdvp, 0);
VOP_UNLOCK(fvp, 0);
@ -1178,7 +1178,7 @@ msdosfs_rename(struct vop_rename_args *ap)
* to pass the correct name to createde(). Undo this.
*/
if ((ip->de_Attributes & ATTR_DIRECTORY) != 0)
bcopy(oldname, ip->de_Name, 11);
memcpy(ip->de_Name, oldname, 11);
ip->de_refcnt++;
zp->de_fndoffset = from_diroffset;
error = removede(zp, ip);
@ -1324,7 +1324,7 @@ msdosfs_mkdir(struct vop_mkdir_args *ap)
if (error)
goto bad2;
bzero(&ndirent, sizeof(ndirent));
memset(&ndirent, 0, sizeof(ndirent));
ndirent.de_pmp = pmp;
ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
getnanotime(&ts);
@ -1338,8 +1338,8 @@ msdosfs_mkdir(struct vop_mkdir_args *ap)
bn = cntobn(pmp, newcluster);
/* always succeeds */
bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0, 0);
bzero(bp->b_data, pmp->pm_bpcluster);
bcopy(&dosdirtemplate, bp->b_data, sizeof dosdirtemplate);
memset(bp->b_data, 0, pmp->pm_bpcluster);
memcpy(bp->b_data, &dosdirtemplate, sizeof dosdirtemplate);
denp = (struct direntry *)bp->b_data;
putushort(denp[0].deStartCluster, newcluster);
putushort(denp[0].deCDate, ndirent.de_CDate);
@ -1504,7 +1504,7 @@ msdosfs_readdir(struct vop_readdir_args *ap)
/*
* To be safe, initialize dirbuf
*/
bzero(dirbuf.d_name, sizeof(dirbuf.d_name));
memset(dirbuf.d_name, 0, sizeof(dirbuf.d_name));
/*
* If the user buffer is smaller than the size of one dos directory