aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2020-10-02 20:44:10 -0400
committerGitHub <[email protected]>2020-10-02 17:44:10 -0700
commit4d55ea811d4f5b832398f4e3b24c4da365956d62 (patch)
treec799540f0984809efa47a3b5d2218940def15297
parent5b525165e9113e7faabd230b504ae4e9b85d35a5 (diff)
Throw const on some strings
In C, const indicates to the reader that mutation will not occur. It can also serve as a hint about ownership. Add const in a few places where it makes sense. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #10997
-rw-r--r--include/os/freebsd/zfs/sys/zfs_ctldir.h2
-rw-r--r--include/os/freebsd/zfs/sys/zfs_dir.h4
-rw-r--r--include/os/freebsd/zfs/sys/zfs_vnops.h14
-rw-r--r--include/os/linux/zfs/sys/zfs_ctldir.h18
-rw-r--r--include/os/linux/zfs/sys/zfs_vnops.h4
-rw-r--r--include/sys/dmu.h2
-rw-r--r--include/sys/spa.h6
-rw-r--r--include/sys/u8_textprep.h2
-rw-r--r--include/sys/zfs_znode.h13
-rw-r--r--module/os/freebsd/zfs/zfs_ctldir.c2
-rw-r--r--module/os/freebsd/zfs/zfs_vnops.c45
-rw-r--r--module/os/linux/zfs/zfs_ctldir.c25
-rw-r--r--module/os/linux/zfs/zfs_dir.c9
-rw-r--r--module/os/linux/zfs/zfs_vnops.c4
-rw-r--r--module/unicode/u8_textprep.c2
-rw-r--r--module/zfs/dmu_objset.c2
-rw-r--r--module/zfs/spa.c8
-rw-r--r--module/zfs/zfeature.c2
-rw-r--r--module/zfs/zfs_ioctl.c31
-rw-r--r--module/zfs/zfs_log.c12
20 files changed, 99 insertions, 108 deletions
diff --git a/include/os/freebsd/zfs/sys/zfs_ctldir.h b/include/os/freebsd/zfs/sys/zfs_ctldir.h
index 28a026603..da02863a7 100644
--- a/include/os/freebsd/zfs/sys/zfs_ctldir.h
+++ b/include/os/freebsd/zfs/sys/zfs_ctldir.h
@@ -48,7 +48,7 @@ int zfsctl_root(zfsvfs_t *, int, vnode_t **);
void zfsctl_init(void);
void zfsctl_fini(void);
boolean_t zfsctl_is_node(vnode_t *);
-int zfsctl_snapshot_unmount(char *snapname, int flags);
+int zfsctl_snapshot_unmount(const char *snapname, int flags);
int zfsctl_rename_snapshot(const char *from, const char *to);
int zfsctl_destroy_snapshot(const char *snapname, int force);
int zfsctl_umount_snapshots(vfs_t *, int, cred_t *);
diff --git a/include/os/freebsd/zfs/sys/zfs_dir.h b/include/os/freebsd/zfs/sys/zfs_dir.h
index f6f8ab5c4..4197e1188 100644
--- a/include/os/freebsd/zfs/sys/zfs_dir.h
+++ b/include/os/freebsd/zfs/sys/zfs_dir.h
@@ -52,11 +52,7 @@ extern int zfs_dirent_lookup(znode_t *, const char *, znode_t **, int);
extern int zfs_link_create(znode_t *, const char *, znode_t *, dmu_tx_t *, int);
extern int zfs_link_destroy(znode_t *, const char *, znode_t *, dmu_tx_t *, int,
boolean_t *);
-#if 0
-extern int zfs_dirlook(vnode_t *, const char *, vnode_t **, int);
-#else
extern int zfs_dirlook(znode_t *, const char *name, znode_t **);
-#endif
extern void zfs_mknode(znode_t *, vattr_t *, dmu_tx_t *, cred_t *,
uint_t, znode_t **, zfs_acl_ids_t *);
extern void zfs_rmnode(znode_t *);
diff --git a/include/os/freebsd/zfs/sys/zfs_vnops.h b/include/os/freebsd/zfs/sys/zfs_vnops.h
index 6237372b9..587650af6 100644
--- a/include/os/freebsd/zfs/sys/zfs_vnops.h
+++ b/include/os/freebsd/zfs/sys/zfs_vnops.h
@@ -32,21 +32,21 @@ int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset,
uint64_t size, struct vm_page **ppa, dmu_tx_t *tx);
int dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
int *rbehind, int *rahead, int last_size);
-extern int zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags);
-extern int zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap,
+extern int zfs_remove(znode_t *dzp, const char *name, cred_t *cr, int flags);
+extern int zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap,
znode_t **zpp, cred_t *cr, int flags, vsecattr_t *vsecp);
-extern int zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd,
+extern int zfs_rmdir(znode_t *dzp, const char *name, znode_t *cwd,
cred_t *cr, int flags);
extern int zfs_setattr(znode_t *zp, vattr_t *vap, int flag, cred_t *cr);
-extern int zfs_rename(znode_t *sdzp, char *snm, znode_t *tdzp,
- char *tnm, cred_t *cr, int flags);
+extern int zfs_rename(znode_t *sdzp, const char *snm, znode_t *tdzp,
+ const char *tnm, cred_t *cr, int flags);
extern int zfs_symlink(znode_t *dzp, const char *name, vattr_t *vap,
const char *link, znode_t **zpp, cred_t *cr, int flags);
extern int zfs_link(znode_t *tdzp, znode_t *sp,
- char *name, cred_t *cr, int flags);
+ const char *name, cred_t *cr, int flags);
extern int zfs_space(znode_t *zp, int cmd, struct flock *bfp, int flag,
offset_t offset, cred_t *cr);
-extern int zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
+extern int zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl,
int mode, znode_t **zpp, cred_t *cr, int flag, vsecattr_t *vsecp);
extern int zfs_setsecattr(znode_t *zp, vsecattr_t *vsecp, int flag,
cred_t *cr);
diff --git a/include/os/linux/zfs/sys/zfs_ctldir.h b/include/os/linux/zfs/sys/zfs_ctldir.h
index 51933bc4f..beee34979 100644
--- a/include/os/linux/zfs/sys/zfs_ctldir.h
+++ b/include/os/linux/zfs/sys/zfs_ctldir.h
@@ -60,22 +60,22 @@ extern boolean_t zfsctl_is_snapdir(struct inode *ip);
extern int zfsctl_fid(struct inode *ip, fid_t *fidp);
/* zfsctl '.zfs' functions */
-extern int zfsctl_root_lookup(struct inode *dip, char *name,
+extern int zfsctl_root_lookup(struct inode *dip, const char *name,
struct inode **ipp, int flags, cred_t *cr, int *direntflags,
pathname_t *realpnp);
/* zfsctl '.zfs/snapshot' functions */
-extern int zfsctl_snapdir_lookup(struct inode *dip, char *name,
+extern int zfsctl_snapdir_lookup(struct inode *dip, const char *name,
struct inode **ipp, int flags, cred_t *cr, int *direntflags,
pathname_t *realpnp);
-extern int zfsctl_snapdir_rename(struct inode *sdip, char *sname,
- struct inode *tdip, char *tname, cred_t *cr, int flags);
-extern int zfsctl_snapdir_remove(struct inode *dip, char *name, cred_t *cr,
- int flags);
-extern int zfsctl_snapdir_mkdir(struct inode *dip, char *dirname, vattr_t *vap,
- struct inode **ipp, cred_t *cr, int flags);
+extern int zfsctl_snapdir_rename(struct inode *sdip, const char *sname,
+ struct inode *tdip, const char *tname, cred_t *cr, int flags);
+extern int zfsctl_snapdir_remove(struct inode *dip, const char *name,
+ cred_t *cr, int flags);
+extern int zfsctl_snapdir_mkdir(struct inode *dip, const char *dirname,
+ vattr_t *vap, struct inode **ipp, cred_t *cr, int flags);
extern int zfsctl_snapshot_mount(struct path *path, int flags);
-extern int zfsctl_snapshot_unmount(char *snapname, int flags);
+extern int zfsctl_snapshot_unmount(const char *snapname, int flags);
extern int zfsctl_snapshot_unmount_delay(spa_t *spa, uint64_t objsetid,
int delay);
extern int zfsctl_snapdir_vget(struct super_block *sb, uint64_t objsetid,
diff --git a/include/os/linux/zfs/sys/zfs_vnops.h b/include/os/linux/zfs/sys/zfs_vnops.h
index 24a2082d3..2b41f3863 100644
--- a/include/os/linux/zfs/sys/zfs_vnops.h
+++ b/include/os/linux/zfs/sys/zfs_vnops.h
@@ -46,8 +46,8 @@ extern int zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr);
extern int zfs_write_simple(znode_t *zp, const void *data, size_t len,
loff_t pos, size_t *resid);
extern int zfs_access(struct inode *ip, int mode, int flag, cred_t *cr);
-extern int zfs_lookup(znode_t *dzp, char *nm, znode_t **zpp,
- int flags, cred_t *cr, int *direntflags, pathname_t *realpnp);
+extern int zfs_lookup(znode_t *dzp, char *nm, znode_t **zpp, int flags,
+ cred_t *cr, int *direntflags, pathname_t *realpnp);
extern int zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
int mode, znode_t **zpp, cred_t *cr, int flag, vsecattr_t *vsecp);
extern int zfs_tmpfile(struct inode *dip, vattr_t *vapzfs, int excl,
diff --git a/include/sys/dmu.h b/include/sys/dmu.h
index d6efe2595..9c700e2d7 100644
--- a/include/sys/dmu.h
+++ b/include/sys/dmu.h
@@ -1009,7 +1009,7 @@ extern int dmu_objset_blksize(objset_t *os);
extern int dmu_snapshot_list_next(objset_t *os, int namelen, char *name,
uint64_t *id, uint64_t *offp, boolean_t *case_conflict);
extern int dmu_snapshot_lookup(objset_t *os, const char *name, uint64_t *val);
-extern int dmu_snapshot_realname(objset_t *os, char *name, char *real,
+extern int dmu_snapshot_realname(objset_t *os, const char *name, char *real,
int maxlen, boolean_t *conflict);
extern int dmu_dir_list_next(objset_t *os, int namelen, char *name,
uint64_t *idp, uint64_t *offp);
diff --git a/include/sys/spa.h b/include/sys/spa.h
index ddce8cc91..045431c20 100644
--- a/include/sys/spa.h
+++ b/include/sys/spa.h
@@ -768,12 +768,12 @@ extern int spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
extern int spa_import(char *pool, nvlist_t *config, nvlist_t *props,
uint64_t flags);
extern nvlist_t *spa_tryimport(nvlist_t *tryconfig);
-extern int spa_destroy(char *pool);
+extern int spa_destroy(const char *pool);
extern int spa_checkpoint(const char *pool);
extern int spa_checkpoint_discard(const char *pool);
-extern int spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
+extern int spa_export(const char *pool, nvlist_t **oldconfig, boolean_t force,
boolean_t hardforce);
-extern int spa_reset(char *pool);
+extern int spa_reset(const char *pool);
extern void spa_async_request(spa_t *spa, int flag);
extern void spa_async_unrequest(spa_t *spa, int flag);
extern void spa_async_suspend(spa_t *spa);
diff --git a/include/sys/u8_textprep.h b/include/sys/u8_textprep.h
index f8b5bed6e..09ab13af2 100644
--- a/include/sys/u8_textprep.h
+++ b/include/sys/u8_textprep.h
@@ -101,7 +101,7 @@ extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int);
#define U8_ILLEGAL_CHAR (-1)
#define U8_OUT_OF_RANGE_CHAR (-2)
-extern int u8_validate(char *, size_t, char **, int, int *);
+extern int u8_validate(const char *, size_t, char **, int, int *);
extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *);
extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t,
int *);
diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h
index d7823221e..4138f6eba 100644
--- a/include/sys/zfs_znode.h
+++ b/include/sys/zfs_znode.h
@@ -262,19 +262,20 @@ extern boolean_t zfs_get_vfs_flag_unmounted(objset_t *os);
extern void zfs_znode_dmu_fini(znode_t *);
extern void zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *dzp, znode_t *zp, char *name, vsecattr_t *, zfs_fuid_info_t *,
- vattr_t *vap);
+ znode_t *dzp, znode_t *zp, const char *name, vsecattr_t *,
+ zfs_fuid_info_t *, vattr_t *vap);
extern int zfs_log_create_txtype(zil_create_t, vsecattr_t *vsecp,
vattr_t *vap);
extern void zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *dzp, char *name, uint64_t foid, boolean_t unlinked);
+ znode_t *dzp, const char *name, uint64_t foid, boolean_t unlinked);
#define ZFS_NO_OBJECT 0 /* no object id */
extern void zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *dzp, znode_t *zp, char *name);
+ znode_t *dzp, znode_t *zp, const char *name);
extern void zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *dzp, znode_t *zp, char *name, char *link);
+ znode_t *dzp, znode_t *zp, const char *name, const char *link);
extern void zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *sdzp, char *sname, znode_t *tdzp, char *dname, znode_t *szp);
+ znode_t *sdzp, const char *sname, znode_t *tdzp, const char *dname,
+ znode_t *szp);
extern void zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
znode_t *zp, offset_t off, ssize_t len, int ioflag,
zil_callback_t callback, void *callback_data);
diff --git a/module/os/freebsd/zfs/zfs_ctldir.c b/module/os/freebsd/zfs/zfs_ctldir.c
index 0fe32b195..5fd367b0c 100644
--- a/module/os/freebsd/zfs/zfs_ctldir.c
+++ b/module/os/freebsd/zfs/zfs_ctldir.c
@@ -1327,7 +1327,7 @@ zfsctl_umount_snapshots(vfs_t *vfsp, int fflags, cred_t *cr)
}
int
-zfsctl_snapshot_unmount(char *snapname, int flags __unused)
+zfsctl_snapshot_unmount(const char *snapname, int flags __unused)
{
vfs_t *vfsp = NULL;
zfsvfs_t *zfsvfs = NULL;
diff --git a/module/os/freebsd/zfs/zfs_vnops.c b/module/os/freebsd/zfs/zfs_vnops.c
index 79202b60a..31c1f81d0 100644
--- a/module/os/freebsd/zfs/zfs_vnops.c
+++ b/module/os/freebsd/zfs/zfs_vnops.c
@@ -104,14 +104,6 @@ VFS_SMR_DECLARE;
#define vm_page_wire_unlock(pp) vm_page_unlock(pp)
#endif
-static int
-zfs_u8_validate(const char *u8str, size_t n, char **list, int flag, int *errnum)
-{
-
- return (u8_validate(__DECONST(char *, u8str), n, list, flag, errnum));
-}
-#define u8_validate zfs_u8_validate
-
#ifdef DEBUG_VFS_LOCKS
#define VNCHECKREF(vp) \
VNASSERT((vp)->v_holdcnt > 0 && (vp)->v_usecount > 0, vp, \
@@ -1536,8 +1528,9 @@ zfs_lookup_lock(vnode_t *dvp, vnode_t *vp, const char *name, int lkflags)
*/
/* ARGSUSED */
static int
-zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp,
- int nameiop, cred_t *cr, kthread_t *td, int flags, boolean_t cached)
+zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp,
+ struct componentname *cnp, int nameiop, cred_t *cr, kthread_t *td,
+ int flags, boolean_t cached)
{
znode_t *zdp = VTOZ(dvp);
znode_t *zp;
@@ -1561,7 +1554,8 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp,
}
}
- DTRACE_PROBE2(zfs__fastpath__lookup__miss, vnode_t *, dvp, char *, nm);
+ DTRACE_PROBE2(zfs__fastpath__lookup__miss, vnode_t *, dvp,
+ const char *, nm);
ZFS_ENTER(zfsvfs);
ZFS_VERIFY_ZP(zdp);
@@ -1778,7 +1772,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp,
/* ARGSUSED */
int
-zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl, int mode,
+zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl, int mode,
znode_t **zpp, cred_t *cr, int flag, vsecattr_t *vsecp)
{
znode_t *zp;
@@ -1945,7 +1939,7 @@ out:
/*ARGSUSED*/
static int
-zfs_remove_(vnode_t *dvp, vnode_t *vp, char *name, cred_t *cr)
+zfs_remove_(vnode_t *dvp, vnode_t *vp, const char *name, cred_t *cr)
{
znode_t *dzp = VTOZ(dvp);
znode_t *zp;
@@ -2059,13 +2053,13 @@ out:
static int
-zfs_lookup_internal(znode_t *dzp, char *name, vnode_t **vpp,
+zfs_lookup_internal(znode_t *dzp, const char *name, vnode_t **vpp,
struct componentname *cnp, int nameiop)
{
zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
int error;
- cnp->cn_nameptr = name;
+ cnp->cn_nameptr = __DECONST(char *, name);
cnp->cn_namelen = strlen(name);
cnp->cn_nameiop = nameiop;
cnp->cn_flags = ISLASTCN | SAVENAME;
@@ -2096,7 +2090,7 @@ zfs_lookup_internal(znode_t *dzp, char *name, vnode_t **vpp,
}
int
-zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags)
+zfs_remove(znode_t *dzp, const char *name, cred_t *cr, int flags)
{
vnode_t *vp;
int error;
@@ -2131,8 +2125,8 @@ zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags)
*/
/*ARGSUSED*/
int
-zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap, znode_t **zpp, cred_t *cr,
- int flags, vsecattr_t *vsecp)
+zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp,
+ cred_t *cr, int flags, vsecattr_t *vsecp)
{
znode_t *zp;
zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
@@ -2298,7 +2292,7 @@ zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap, znode_t **zpp, cred_t *cr,
*/
/*ARGSUSED*/
static int
-zfs_rmdir_(vnode_t *dvp, vnode_t *vp, char *name, cred_t *cr)
+zfs_rmdir_(vnode_t *dvp, vnode_t *vp, const char *name, cred_t *cr)
{
znode_t *dzp = VTOZ(dvp);
znode_t *zp = VTOZ(vp);
@@ -2360,7 +2354,7 @@ out:
}
int
-zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd, cred_t *cr, int flags)
+zfs_rmdir(znode_t *dzp, const char *name, znode_t *cwd, cred_t *cr, int flags)
{
struct componentname cn;
vnode_t *vp;
@@ -3934,8 +3928,8 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp,
znode_t *sdzp, *tdzp, *szp, *tzp;
zilog_t *zilog = NULL;
dmu_tx_t *tx;
- char *snm = scnp->cn_nameptr;
- char *tnm = tcnp->cn_nameptr;
+ const char *snm = scnp->cn_nameptr;
+ const char *tnm = tcnp->cn_nameptr;
int error = 0;
bool want_seqc_end __maybe_unused = false;
@@ -4201,7 +4195,7 @@ out: /* original two vnodes are locked */
}
int
-zfs_rename(znode_t *sdzp, char *sname, znode_t *tdzp, char *tname,
+zfs_rename(znode_t *sdzp, const char *sname, znode_t *tdzp, const char *tname,
cred_t *cr, int flags)
{
struct componentname scn, tcn;
@@ -4360,8 +4354,7 @@ zfs_symlink(znode_t *dzp, const char *name, vattr_t *vap,
*/
(void) zfs_link_create(dzp, name, zp, tx, ZNEW);
- zfs_log_symlink(zilog, tx, txtype, dzp, zp,
- __DECONST(char *, name), __DECONST(char *, link));
+ zfs_log_symlink(zilog, tx, txtype, dzp, zp, name, link);
*zpp = zp;
zfs_acl_ids_free(&acl_ids);
@@ -4432,7 +4425,7 @@ zfs_readlink(vnode_t *vp, uio_t *uio, cred_t *cr, caller_context_t *ct)
*/
/* ARGSUSED */
int
-zfs_link(znode_t *tdzp, znode_t *szp, char *name, cred_t *cr,
+zfs_link(znode_t *tdzp, znode_t *szp, const char *name, cred_t *cr,
int flags)
{
znode_t *tzp;
diff --git a/module/os/linux/zfs/zfs_ctldir.c b/module/os/linux/zfs/zfs_ctldir.c
index 26e785a0d..c13a97712 100644
--- a/module/os/linux/zfs/zfs_ctldir.c
+++ b/module/os/linux/zfs/zfs_ctldir.c
@@ -131,7 +131,7 @@ static void zfsctl_snapshot_unmount_delay_impl(zfs_snapentry_t *se, int delay);
* the snapshot name and provided mount point. No reference is taken.
*/
static zfs_snapentry_t *
-zfsctl_snapshot_alloc(char *full_name, char *full_path, spa_t *spa,
+zfsctl_snapshot_alloc(const char *full_name, const char *full_path, spa_t *spa,
uint64_t objsetid, struct dentry *root_dentry)
{
zfs_snapentry_t *se;
@@ -261,13 +261,13 @@ snapentry_compare_by_objsetid(const void *a, const void *b)
* NULL will be returned.
*/
static zfs_snapentry_t *
-zfsctl_snapshot_find_by_name(char *snapname)
+zfsctl_snapshot_find_by_name(const char *snapname)
{
zfs_snapentry_t *se, search;
ASSERT(RW_LOCK_HELD(&zfs_snapshot_lock));
- search.se_name = snapname;
+ search.se_name = (char *)snapname;
se = avl_find(&zfs_snapshots_by_name, &search, NULL);
if (se)
zfsctl_snapshot_hold(se);
@@ -301,7 +301,7 @@ zfsctl_snapshot_find_by_objsetid(spa_t *spa, uint64_t objsetid)
* removed, renamed, and added back to the new correct location in the tree.
*/
static int
-zfsctl_snapshot_rename(char *old_snapname, char *new_snapname)
+zfsctl_snapshot_rename(const char *old_snapname, const char *new_snapname)
{
zfs_snapentry_t *se;
@@ -410,7 +410,7 @@ zfsctl_snapshot_unmount_delay(spa_t *spa, uint64_t objsetid, int delay)
* and zero when unmounted.
*/
static boolean_t
-zfsctl_snapshot_ismounted(char *snapname)
+zfsctl_snapshot_ismounted(const char *snapname)
{
zfs_snapentry_t *se;
boolean_t ismounted = B_FALSE;
@@ -751,7 +751,7 @@ out:
* Special case the handling of "..".
*/
int
-zfsctl_root_lookup(struct inode *dip, char *name, struct inode **ipp,
+zfsctl_root_lookup(struct inode *dip, const char *name, struct inode **ipp,
int flags, cred_t *cr, int *direntflags, pathname_t *realpnp)
{
zfsvfs_t *zfsvfs = ITOZSB(dip);
@@ -784,7 +784,7 @@ zfsctl_root_lookup(struct inode *dip, char *name, struct inode **ipp,
* snapshot if it exist, creating the pseudo filesystem inode as necessary.
*/
int
-zfsctl_snapdir_lookup(struct inode *dip, char *name, struct inode **ipp,
+zfsctl_snapdir_lookup(struct inode *dip, const char *name, struct inode **ipp,
int flags, cred_t *cr, int *direntflags, pathname_t *realpnp)
{
zfsvfs_t *zfsvfs = ITOZSB(dip);
@@ -815,8 +815,8 @@ zfsctl_snapdir_lookup(struct inode *dip, char *name, struct inode **ipp,
* to the '.zfs/snapshot' directory snapshots cannot be moved elsewhere.
*/
int
-zfsctl_snapdir_rename(struct inode *sdip, char *snm,
- struct inode *tdip, char *tnm, cred_t *cr, int flags)
+zfsctl_snapdir_rename(struct inode *sdip, const char *snm,
+ struct inode *tdip, const char *tnm, cred_t *cr, int flags)
{
zfsvfs_t *zfsvfs = ITOZSB(sdip);
char *to, *from, *real, *fsname;
@@ -893,7 +893,8 @@ out:
* the removal of the snapshot with the given name.
*/
int
-zfsctl_snapdir_remove(struct inode *dip, char *name, cred_t *cr, int flags)
+zfsctl_snapdir_remove(struct inode *dip, const char *name, cred_t *cr,
+ int flags)
{
zfsvfs_t *zfsvfs = ITOZSB(dip);
char *snapname, *real;
@@ -941,7 +942,7 @@ out:
* the creation of a new snapshot with the given name.
*/
int
-zfsctl_snapdir_mkdir(struct inode *dip, char *dirname, vattr_t *vap,
+zfsctl_snapdir_mkdir(struct inode *dip, const char *dirname, vattr_t *vap,
struct inode **ipp, cred_t *cr, int flags)
{
zfsvfs_t *zfsvfs = ITOZSB(dip);
@@ -1001,7 +1002,7 @@ exportfs_flush(void)
* it's in use, the unmount will fail harmlessly.
*/
int
-zfsctl_snapshot_unmount(char *snapname, int flags)
+zfsctl_snapshot_unmount(const char *snapname, int flags)
{
char *argv[] = { "/usr/bin/env", "umount", "-t", "zfs", "-n", NULL,
NULL };
diff --git a/module/os/linux/zfs/zfs_dir.c b/module/os/linux/zfs/zfs_dir.c
index 383657208..207a51d75 100644
--- a/module/os/linux/zfs/zfs_dir.c
+++ b/module/os/linux/zfs/zfs_dir.c
@@ -60,8 +60,9 @@
* of names after deciding which is the appropriate lookup interface.
*/
static int
-zfs_match_find(zfsvfs_t *zfsvfs, znode_t *dzp, char *name, matchtype_t mt,
- boolean_t update, int *deflags, pathname_t *rpnp, uint64_t *zoid)
+zfs_match_find(zfsvfs_t *zfsvfs, znode_t *dzp, const char *name,
+ matchtype_t mt, boolean_t update, int *deflags, pathname_t *rpnp,
+ uint64_t *zoid)
{
boolean_t conflict = B_FALSE;
int error;
@@ -139,8 +140,8 @@ zfs_match_find(zfsvfs_t *zfsvfs, znode_t *dzp, char *name, matchtype_t mt,
* but return znode pointers to a single match.
*/
int
-zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name, znode_t **zpp,
- int flag, int *direntflags, pathname_t *realpnp)
+zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name,
+ znode_t **zpp, int flag, int *direntflags, pathname_t *realpnp)
{
zfsvfs_t *zfsvfs = ZTOZSB(dzp);
zfs_dirlock_t *dl;
diff --git a/module/os/linux/zfs/zfs_vnops.c b/module/os/linux/zfs/zfs_vnops.c
index 2d104a500..0932b9b33 100644
--- a/module/os/linux/zfs/zfs_vnops.c
+++ b/module/os/linux/zfs/zfs_vnops.c
@@ -1234,8 +1234,8 @@ zfs_access(struct inode *ip, int mode, int flag, cred_t *cr)
*/
/* ARGSUSED */
int
-zfs_lookup(znode_t *zdp, char *nm, znode_t **zpp, int flags,
- cred_t *cr, int *direntflags, pathname_t *realpnp)
+zfs_lookup(znode_t *zdp, char *nm, znode_t **zpp, int flags, cred_t *cr,
+ int *direntflags, pathname_t *realpnp)
{
zfsvfs_t *zfsvfs = ZTOZSB(zdp);
int error = 0;
diff --git a/module/unicode/u8_textprep.c b/module/unicode/u8_textprep.c
index 65f555d88..be816d728 100644
--- a/module/unicode/u8_textprep.c
+++ b/module/unicode/u8_textprep.c
@@ -330,7 +330,7 @@ const uint8_t u8_valid_max_2nd_byte[0x100] = {
* specific to UTF-8 and Unicode.
*/
int
-u8_validate(char *u8str, size_t n, char **list, int flag, int *errnum)
+u8_validate(const char *u8str, size_t n, char **list, int flag, int *errnum)
{
uchar_t *ib;
uchar_t *ibtail;
diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c
index b1590d7db..af5935e23 100644
--- a/module/zfs/dmu_objset.c
+++ b/module/zfs/dmu_objset.c
@@ -2413,7 +2413,7 @@ dmu_objset_is_snapshot(objset_t *os)
}
int
-dmu_snapshot_realname(objset_t *os, char *name, char *real, int maxlen,
+dmu_snapshot_realname(objset_t *os, const char *name, char *real, int maxlen,
boolean_t *conflict)
{
dsl_dataset_t *ds = os->os_dsl_dataset;
diff --git a/module/zfs/spa.c b/module/zfs/spa.c
index 532f04b91..2c70cf701 100644
--- a/module/zfs/spa.c
+++ b/module/zfs/spa.c
@@ -6225,7 +6225,7 @@ spa_tryimport(nvlist_t *tryconfig)
* we don't sync the labels or remove the configuration cache.
*/
static int
-spa_export_common(char *pool, int new_state, nvlist_t **oldconfig,
+spa_export_common(const char *pool, int new_state, nvlist_t **oldconfig,
boolean_t force, boolean_t hardforce)
{
spa_t *spa;
@@ -6369,7 +6369,7 @@ export_spa:
* Destroy a storage pool.
*/
int
-spa_destroy(char *pool)
+spa_destroy(const char *pool)
{
return (spa_export_common(pool, POOL_STATE_DESTROYED, NULL,
B_FALSE, B_FALSE));
@@ -6379,7 +6379,7 @@ spa_destroy(char *pool)
* Export a storage pool.
*/
int
-spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
+spa_export(const char *pool, nvlist_t **oldconfig, boolean_t force,
boolean_t hardforce)
{
return (spa_export_common(pool, POOL_STATE_EXPORTED, oldconfig,
@@ -6391,7 +6391,7 @@ spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
* from the namespace in any way.
*/
int
-spa_reset(char *pool)
+spa_reset(const char *pool)
{
return (spa_export_common(pool, POOL_STATE_UNINITIALIZED, NULL,
B_FALSE, B_FALSE));
diff --git a/module/zfs/zfeature.c b/module/zfs/zfeature.c
index 3757443a5..9d16fff81 100644
--- a/module/zfs/zfeature.c
+++ b/module/zfs/zfeature.c
@@ -203,7 +203,7 @@ spa_features_check(spa_t *spa, boolean_t for_write,
supported = B_FALSE;
if (NULL != unsup_feat) {
- char *desc = "";
+ const char *desc = "";
if (zap_lookup(os, spa->spa_feat_desc_obj,
za->za_name, 1, MAXPATHLEN, buf) == 0)
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index d2550750c..94cd1a3dc 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -270,7 +270,7 @@ static int zfs_ioc_userspace_upgrade(zfs_cmd_t *zc);
static int zfs_ioc_id_quota_upgrade(zfs_cmd_t *zc);
static int zfs_check_settable(const char *name, nvpair_t *property,
cred_t *cr);
-static int zfs_check_clearable(char *dataset, nvlist_t *props,
+static int zfs_check_clearable(const char *dataset, nvlist_t *props,
nvlist_t **errors);
static int zfs_fill_zplprops_root(uint64_t, nvlist_t *, nvlist_t *,
boolean_t *);
@@ -498,7 +498,7 @@ zfs_secpolicy_write_perms(const char *name, const char *perm, cred_t *cr)
* Returns 0 for success, non-zero for access and other errors.
*/
static int
-zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
+zfs_set_slabel_policy(const char *name, const char *strval, cred_t *cr)
{
#ifdef HAVE_MLSLABEL
char ds_hexsl[MAXNAMELEN];
@@ -553,7 +553,7 @@ zfs_set_slabel_policy(const char *name, char *strval, cred_t *cr)
*/
if (strcasecmp(ds_hexsl, ZFS_MLSLABEL_DEFAULT) != 0) {
objset_t *os;
- static char *setsl_tag = "setsl_tag";
+ static const char *setsl_tag = "setsl_tag";
/*
* Try to own the dataset; abort if there is any error,
@@ -680,7 +680,7 @@ zfs_secpolicy_send(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
dsl_pool_t *dp;
dsl_dataset_t *ds;
- char *cp;
+ const char *cp;
int error;
/*
@@ -1443,7 +1443,7 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
nvlist_t *rootprops = NULL;
nvlist_t *zplprops = NULL;
dsl_crypto_params_t *dcp = NULL;
- char *spa_name = zc->zc_name;
+ const char *spa_name = zc->zc_name;
boolean_t unload_wkey = B_TRUE;
if ((error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
@@ -1997,7 +1997,7 @@ static int
zfs_ioc_vdev_setpath(zfs_cmd_t *zc)
{
spa_t *spa;
- char *path = zc->zc_value;
+ const char *path = zc->zc_value;
uint64_t guid = zc->zc_guid;
int error;
@@ -2014,7 +2014,7 @@ static int
zfs_ioc_vdev_setfru(zfs_cmd_t *zc)
{
spa_t *spa;
- char *fru = zc->zc_value;
+ const char *fru = zc->zc_value;
uint64_t guid = zc->zc_guid;
int error;
@@ -2351,8 +2351,7 @@ zfs_prop_set_userquota(const char *dsname, nvpair_t *pair)
const char *propname = nvpair_name(pair);
uint64_t *valary;
unsigned int vallen;
- const char *domain;
- char *dash;
+ const char *dash, *domain;
zfs_userquota_prop_t type;
uint64_t rid;
uint64_t quota;
@@ -2405,7 +2404,7 @@ zfs_prop_set_special(const char *dsname, zprop_source_t source,
const char *propname = nvpair_name(pair);
zfs_prop_t prop = zfs_name_to_prop(propname);
uint64_t intval = 0;
- char *strval = NULL;
+ const char *strval = NULL;
int err = -1;
if (prop == ZPROP_INVAL) {
@@ -2531,7 +2530,7 @@ zfs_set_prop_nvlist(const char *dsname, zprop_source_t source, nvlist_t *nvl,
nvpair_t *propval;
int rv = 0;
uint64_t intval;
- char *strval;
+ const char *strval;
nvlist_t *genericnvl = fnvlist_alloc();
nvlist_t *retrynvl = fnvlist_alloc();
@@ -3349,7 +3348,7 @@ zfs_ioc_clone(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
{
int error = 0;
nvlist_t *nvprops = NULL;
- char *origin_name;
+ const char *origin_name;
origin_name = fnvlist_lookup_string(innvl, "origin");
(void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
@@ -3475,10 +3474,10 @@ static const zfs_ioc_key_t zfs_keys_log_history[] = {
static int
zfs_ioc_log_history(const char *unused, nvlist_t *innvl, nvlist_t *outnvl)
{
- char *message;
+ const char *message;
+ char *poolname;
spa_t *spa;
int error;
- char *poolname;
/*
* The poolname in the ioctl is not set, we get it from the TSD,
@@ -3574,7 +3573,7 @@ zfs_unmount_snap(const char *snapname)
if (strchr(snapname, '@') == NULL)
return;
- (void) zfsctl_snapshot_unmount((char *)snapname, MNT_FORCE);
+ (void) zfsctl_snapshot_unmount(snapname, MNT_FORCE);
}
/* ARGSUSED */
@@ -4617,7 +4616,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
* pointed at by errlist is NULL.
*/
static int
-zfs_check_clearable(char *dataset, nvlist_t *props, nvlist_t **errlist)
+zfs_check_clearable(const char *dataset, nvlist_t *props, nvlist_t **errlist)
{
zfs_cmd_t *zc;
nvpair_t *pair, *next_pair;
diff --git a/module/zfs/zfs_log.c b/module/zfs/zfs_log.c
index fb44007fe..4bb529f78 100644
--- a/module/zfs/zfs_log.c
+++ b/module/zfs/zfs_log.c
@@ -299,7 +299,7 @@ zfs_xattr_owner_unlinked(znode_t *zp)
*/
void
zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *dzp, znode_t *zp, char *name, vsecattr_t *vsecp,
+ znode_t *dzp, znode_t *zp, const char *name, vsecattr_t *vsecp,
zfs_fuid_info_t *fuidp, vattr_t *vap)
{
itx_t *itx;
@@ -413,7 +413,7 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
*/
void
zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *dzp, char *name, uint64_t foid, boolean_t unlinked)
+ znode_t *dzp, const char *name, uint64_t foid, boolean_t unlinked)
{
itx_t *itx;
lr_remove_t *lr;
@@ -448,7 +448,7 @@ zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
*/
void
zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *dzp, znode_t *zp, char *name)
+ znode_t *dzp, znode_t *zp, const char *name)
{
itx_t *itx;
lr_link_t *lr;
@@ -471,7 +471,7 @@ zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
*/
void
zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *dzp, znode_t *zp, char *name, char *link)
+ znode_t *dzp, znode_t *zp, const char *name, const char *link)
{
itx_t *itx;
lr_create_t *lr;
@@ -502,8 +502,8 @@ zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
* Handles TX_RENAME transactions.
*/
void
-zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
- znode_t *sdzp, char *sname, znode_t *tdzp, char *dname, znode_t *szp)
+zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, znode_t *sdzp,
+ const char *sname, znode_t *tdzp, const char *dname, znode_t *szp)
{
itx_t *itx;
lr_rename_t *lr;