Skip to content

Commit 996b232

Browse files
author
Darrick J. Wong
committed
xfs: constify the name argument to various directory functions
Various directory functions do not modify their @name parameter, so mark it const to make that clear. This will enable us to mark the global xfs_name_dotdot variable as const to prevent mischief. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 4166726 commit 996b232

6 files changed

Lines changed: 27 additions & 26 deletions

File tree

fs/xfs/libxfs/xfs_dir2.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ xfs_mode_to_ftype(
5454
*/
5555
xfs_dahash_t
5656
xfs_ascii_ci_hashname(
57-
struct xfs_name *name)
57+
const struct xfs_name *name)
5858
{
59-
xfs_dahash_t hash;
60-
int i;
59+
xfs_dahash_t hash;
60+
int i;
6161

6262
for (i = 0, hash = 0; i < name->len; i++)
6363
hash = tolower(name->name[i]) ^ rol32(hash, 7);
@@ -243,7 +243,7 @@ int
243243
xfs_dir_createname(
244244
struct xfs_trans *tp,
245245
struct xfs_inode *dp,
246-
struct xfs_name *name,
246+
const struct xfs_name *name,
247247
xfs_ino_t inum, /* new entry inode number */
248248
xfs_extlen_t total) /* bmap's total block count */
249249
{
@@ -337,16 +337,16 @@ xfs_dir_cilookup_result(
337337

338338
int
339339
xfs_dir_lookup(
340-
xfs_trans_t *tp,
341-
xfs_inode_t *dp,
342-
struct xfs_name *name,
343-
xfs_ino_t *inum, /* out: inode number */
344-
struct xfs_name *ci_name) /* out: actual name if CI match */
340+
struct xfs_trans *tp,
341+
struct xfs_inode *dp,
342+
const struct xfs_name *name,
343+
xfs_ino_t *inum, /* out: inode number */
344+
struct xfs_name *ci_name) /* out: actual name if CI match */
345345
{
346-
struct xfs_da_args *args;
347-
int rval;
348-
int v; /* type-checking value */
349-
int lock_mode;
346+
struct xfs_da_args *args;
347+
int rval;
348+
int v; /* type-checking value */
349+
int lock_mode;
350350

351351
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
352352
XFS_STATS_INC(dp->i_mount, xs_dir_lookup);
@@ -475,7 +475,7 @@ int
475475
xfs_dir_replace(
476476
struct xfs_trans *tp,
477477
struct xfs_inode *dp,
478-
struct xfs_name *name, /* name of entry to replace */
478+
const struct xfs_name *name, /* name of entry to replace */
479479
xfs_ino_t inum, /* new inode number */
480480
xfs_extlen_t total) /* bmap's total block count */
481481
{
@@ -728,7 +728,7 @@ xfs_dir2_namecheck(
728728
xfs_dahash_t
729729
xfs_dir2_hashname(
730730
struct xfs_mount *mp,
731-
struct xfs_name *name)
731+
const struct xfs_name *name)
732732
{
733733
if (unlikely(xfs_has_asciici(mp)))
734734
return xfs_ascii_ci_hashname(name);

fs/xfs/libxfs/xfs_dir2.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ extern int xfs_dir_isempty(struct xfs_inode *dp);
3939
extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
4040
struct xfs_inode *pdp);
4141
extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
42-
struct xfs_name *name, xfs_ino_t inum,
42+
const struct xfs_name *name, xfs_ino_t inum,
4343
xfs_extlen_t tot);
4444
extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
45-
struct xfs_name *name, xfs_ino_t *inum,
45+
const struct xfs_name *name, xfs_ino_t *inum,
4646
struct xfs_name *ci_name);
4747
extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
4848
struct xfs_name *name, xfs_ino_t ino,
4949
xfs_extlen_t tot);
5050
extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
51-
struct xfs_name *name, xfs_ino_t inum,
51+
const struct xfs_name *name, xfs_ino_t inum,
5252
xfs_extlen_t tot);
5353
extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
5454
struct xfs_name *name);

fs/xfs/libxfs/xfs_dir2_priv.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct xfs_dir3_icfree_hdr {
4040
};
4141

4242
/* xfs_dir2.c */
43-
xfs_dahash_t xfs_ascii_ci_hashname(struct xfs_name *name);
43+
xfs_dahash_t xfs_ascii_ci_hashname(const struct xfs_name *name);
4444
enum xfs_dacmp xfs_ascii_ci_compname(struct xfs_da_args *args,
4545
const unsigned char *name, int len);
4646
extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
@@ -201,7 +201,8 @@ xfs_dir2_data_entsize(
201201
return round_up(len, XFS_DIR2_DATA_ALIGN);
202202
}
203203

204-
xfs_dahash_t xfs_dir2_hashname(struct xfs_mount *mp, struct xfs_name *name);
204+
xfs_dahash_t xfs_dir2_hashname(struct xfs_mount *mp,
205+
const struct xfs_name *name);
205206
enum xfs_dacmp xfs_dir2_compname(struct xfs_da_args *args,
206207
const unsigned char *name, int len);
207208

fs/xfs/xfs_inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,9 @@ xfs_ip2xflags(
658658
*/
659659
int
660660
xfs_lookup(
661-
xfs_inode_t *dp,
662-
struct xfs_name *name,
663-
xfs_inode_t **ipp,
661+
struct xfs_inode *dp,
662+
const struct xfs_name *name,
663+
struct xfs_inode **ipp,
664664
struct xfs_name *ci_name)
665665
{
666666
xfs_ino_t inum;

fs/xfs/xfs_inode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ enum layout_break_reason {
402402

403403
int xfs_release(struct xfs_inode *ip);
404404
void xfs_inactive(struct xfs_inode *ip);
405-
int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name,
405+
int xfs_lookup(struct xfs_inode *dp, const struct xfs_name *name,
406406
struct xfs_inode **ipp, struct xfs_name *ci_name);
407407
int xfs_create(struct user_namespace *mnt_userns,
408408
struct xfs_inode *dp, struct xfs_name *name,

fs/xfs/xfs_trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ DEFINE_IREF_EVENT(xfs_inode_unpin);
933933
DEFINE_IREF_EVENT(xfs_inode_unpin_nowait);
934934

935935
DECLARE_EVENT_CLASS(xfs_namespace_class,
936-
TP_PROTO(struct xfs_inode *dp, struct xfs_name *name),
936+
TP_PROTO(struct xfs_inode *dp, const struct xfs_name *name),
937937
TP_ARGS(dp, name),
938938
TP_STRUCT__entry(
939939
__field(dev_t, dev)
@@ -956,7 +956,7 @@ DECLARE_EVENT_CLASS(xfs_namespace_class,
956956

957957
#define DEFINE_NAMESPACE_EVENT(name) \
958958
DEFINE_EVENT(xfs_namespace_class, name, \
959-
TP_PROTO(struct xfs_inode *dp, struct xfs_name *name), \
959+
TP_PROTO(struct xfs_inode *dp, const struct xfs_name *name), \
960960
TP_ARGS(dp, name))
961961
DEFINE_NAMESPACE_EVENT(xfs_remove);
962962
DEFINE_NAMESPACE_EVENT(xfs_link);

0 commit comments

Comments
 (0)