From: David Disseldorp <ddiss@suse.de>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org,
Al Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
David Disseldorp <ddiss@suse.de>
Subject: [PATCH v4 6/8] initramfs: reuse name_len for dir mtime tracking
Date: Tue, 4 Mar 2025 16:57:49 +1100 [thread overview]
Message-ID: <20250304061020.9815-7-ddiss@suse.de> (raw)
In-Reply-To: <20250304061020.9815-1-ddiss@suse.de>
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>
---
init/initramfs.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/init/initramfs.c b/init/initramfs.c
index df75624cdefbf..b9cacdc54eaf1 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -144,9 +144,8 @@ struct dir_entry {
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;
de = kmalloc(sizeof(struct dir_entry) + nlen, GFP_KERNEL);
@@ -170,7 +169,7 @@ static void __init dir_utime(void)
#else
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 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) {}
#endif
@@ -394,7 +393,7 @@ static int __init do_name(void)
init_mkdir(collected, mode);
init_chown(collected, uid, gid, 0);
init_chmod(collected, mode);
- dir_add(collected, mtime);
+ dir_add(collected, name_len, mtime);
} else if (S_ISBLK(mode) || S_ISCHR(mode) ||
S_ISFIFO(mode) || S_ISSOCK(mode)) {
if (maybe_link() == 0) {
--
2.43.0
next prev parent reply other threads:[~2025-03-04 6:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 5:57 [PATCH v4 0/8] initramfs: kunit tests and cleanups David Disseldorp
2025-03-04 5:57 ` [PATCH v4 1/8] init: add initramfs_internal.h David Disseldorp
2025-03-04 5:57 ` [PATCH v4 2/8] initramfs_test: kunit tests for initramfs unpacking David Disseldorp
2025-03-04 5:57 ` [PATCH v4 3/8] vsprintf: add simple_strntoul David Disseldorp
2025-03-04 5:57 ` [PATCH v4 4/8] initramfs: avoid memcpy for hex header fields David Disseldorp
2025-03-04 5:57 ` [PATCH v4 5/8] initramfs: allocate heap buffers together David Disseldorp
2025-03-04 5:57 ` David Disseldorp [this message]
2025-03-04 5:57 ` [PATCH v4 7/8] initramfs: fix hardlink hash leak without TRAILER David Disseldorp
2025-03-04 5:57 ` [PATCH v4 8/8] initramfs: avoid static buffer for error message David Disseldorp
2025-03-04 8:54 ` [PATCH v4 0/8] initramfs: kunit tests and cleanups Christian Brauner
2025-03-05 13:09 ` [PATCH] initramfs_test: flag kunit_case __refdata to suppress warning David Disseldorp
2025-03-06 7:13 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250304061020.9815-7-ddiss@suse.de \
--to=ddiss@suse.de \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox