initramfs: reuse name_len for dir mtime tracking
We already have a nulterm-inclusive, checked name_len for the directory name, so use that instead of calling strlen(). Signed-off-by: David Disseldorp <ddiss@suse.de> Link: https://lore.kernel.org/r/20250304061020.9815-7-ddiss@suse.de Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
7be37c94da
commit
43094e109f
+3
-4
@@ -144,9 +144,8 @@ struct dir_entry {
|
|||||||
char name[];
|
char name[];
|
||||||
};
|
};
|
||||||
|
|
||||||
static void __init dir_add(const char *name, time64_t mtime)
|
static void __init dir_add(const char *name, size_t nlen, time64_t mtime)
|
||||||
{
|
{
|
||||||
size_t nlen = strlen(name) + 1;
|
|
||||||
struct dir_entry *de;
|
struct dir_entry *de;
|
||||||
|
|
||||||
de = kmalloc(sizeof(struct dir_entry) + nlen, GFP_KERNEL);
|
de = kmalloc(sizeof(struct dir_entry) + nlen, GFP_KERNEL);
|
||||||
@@ -170,7 +169,7 @@ static void __init dir_utime(void)
|
|||||||
#else
|
#else
|
||||||
static void __init do_utime(char *filename, time64_t mtime) {}
|
static void __init do_utime(char *filename, time64_t mtime) {}
|
||||||
static void __init do_utime_path(const struct path *path, time64_t mtime) {}
|
static void __init do_utime_path(const struct path *path, time64_t mtime) {}
|
||||||
static void __init dir_add(const char *name, time64_t mtime) {}
|
static void __init dir_add(const char *name, size_t nlen, time64_t mtime) {}
|
||||||
static void __init dir_utime(void) {}
|
static void __init dir_utime(void) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -394,7 +393,7 @@ static int __init do_name(void)
|
|||||||
init_mkdir(collected, mode);
|
init_mkdir(collected, mode);
|
||||||
init_chown(collected, uid, gid, 0);
|
init_chown(collected, uid, gid, 0);
|
||||||
init_chmod(collected, mode);
|
init_chmod(collected, mode);
|
||||||
dir_add(collected, mtime);
|
dir_add(collected, name_len, mtime);
|
||||||
} else if (S_ISBLK(mode) || S_ISCHR(mode) ||
|
} else if (S_ISBLK(mode) || S_ISCHR(mode) ||
|
||||||
S_ISFIFO(mode) || S_ISSOCK(mode)) {
|
S_ISFIFO(mode) || S_ISSOCK(mode)) {
|
||||||
if (maybe_link() == 0) {
|
if (maybe_link() == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user