aboutsummaryrefslogtreecommitdiff
path: root/sys/fs
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2020-05-25 16:40:48 +0000
committerConrad Meyer <cem@FreeBSD.org>2020-05-25 16:40:48 +0000
commit852c303b61d12d13b56ed7affe31df193aadf9ae (patch)
tree789bb0daba41ca856b37f87708652b4cfcc6403a /sys/fs
parent9085d7d6b86a3435c92d8b817dcc6224ad3e6671 (diff)
copystr(9): Move to deprecate (attempt #2)
This reapplies logical r360944 and r360946 (reverting r360955), with fixed copystr() stand-in replacement macro. Eventually the goal is to convert consumers and kill the macro, but for a first step it helps if the macro is correct. Prior commit message: Unlike the other copy*() functions, it does not serve to copy from one address space to another or protect against potential faults. It's just an older incarnation of the now-more-common strlcpy(). Add a coccinelle script to tools/ which can be used to mechanically convert existing instances where replacement with strlcpy is trivial. In the two cases which matched, fuse_vfsops.c and union_vfsops.c, the code was further refactored manually to simplify. Replace the declaration of copystr() in systm.h with a small macro wrapper around strlcpy (with correction from brooks@ -- thanks). Remove N redundant MI implementations of copystr. For MIPS, this entailed inlining the assembler copystr into the only consumer, copyinstr, and making the latter a leaf function. Reviewed by: jhb (earlier version) Discussed with: brooks (thanks!) Differential Revision: https://reviews.freebsd.org/D24672
Notes
Notes: svn path=/head/; revision=361466
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/fuse/fuse_vfsops.c6
-rw-r--r--sys/fs/unionfs/union_vfsops.c9
2 files changed, 4 insertions, 11 deletions
diff --git a/sys/fs/fuse/fuse_vfsops.c b/sys/fs/fuse/fuse_vfsops.c
index 484a0da216e2..93e2b922b765 100644
--- a/sys/fs/fuse/fuse_vfsops.c
+++ b/sys/fs/fuse/fuse_vfsops.c
@@ -303,8 +303,6 @@ fuse_vfsop_mount(struct mount *mp)
int daemon_timeout;
int fd;
- size_t len;
-
struct cdev *fdev;
struct fuse_data *data = NULL;
struct thread *td;
@@ -437,8 +435,8 @@ fuse_vfsop_mount(struct mount *mp)
strlcat(mp->mnt_stat.f_fstypename, ".", MFSNAMELEN);
strlcat(mp->mnt_stat.f_fstypename, subtype, MFSNAMELEN);
}
- copystr(fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &len);
- bzero(mp->mnt_stat.f_mntfromname + len, MNAMELEN - len);
+ memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
+ strlcpy(mp->mnt_stat.f_mntfromname, fspec, MNAMELEN);
mp->mnt_iosize_max = MAXPHYS;
/* Now handshaking with daemon */
diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c
index d002fb5ef98a..b65696e34c8e 100644
--- a/sys/fs/unionfs/union_vfsops.c
+++ b/sys/fs/unionfs/union_vfsops.c
@@ -83,7 +83,6 @@ unionfs_domount(struct mount *mp)
char *tmp;
char *ep;
int len;
- size_t done;
int below;
uid_t uid;
gid_t gid;
@@ -304,12 +303,8 @@ unionfs_domount(struct mount *mp)
*/
vfs_getnewfsid(mp);
- len = MNAMELEN - 1;
- tmp = mp->mnt_stat.f_mntfromname;
- copystr((below ? "<below>:" : "<above>:"), tmp, len, &done);
- len -= done - 1;
- tmp += done - 1;
- copystr(target, tmp, len, NULL);
+ snprintf(mp->mnt_stat.f_mntfromname, MNAMELEN, "<%s>:%s",
+ below ? "below" : "above", target);
UNIONFSDEBUG("unionfs_mount: from %s, on %s\n",
mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname);