Skip to contentSkip to conversation

bpftool: Mount bpffs on provided dir instead of parent dir

PATCH Superseded Sahil Siddiq 3 participants 5 messages Mar 8, 2024 – Mar 21, 2024

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bpftool: Mount bpffs on provided dir instead of parent dir

When pinning programs/objects under PATH (eg: during "bpftool prog loadall") the bpffs is mounted on the parent dir of PATH in the following situations:
- the given dir exists but it is not bpffs.
- the given dir doesn't exist and the parent dir is not bpffs.

Mounting on the parent dir can also have the unintentional side- effect of hiding other files located under the parent dir.

If the given dir exists but is not bpffs, then the bpffs should be mounted on the given dir and not its parent dir.

Similarly, if the given dir doesn't exist and its parent dir is not bpffs, then the given dir should be created and the bpffs should be mounted on this new dir.

Fixes 2a36c26fe3b8 ("bpftool: Support bpffs mountpoint as pin path for prog loadall")

---
Changes since v1:
- Split "mount_bpffs_for_pin" into two functions:
- mount_bpffs_on_dir
- mount_bpffs_given_file
This is done to improve maintainability and readability.
- Improve error messages
- (mount_bpffs_given_file): If the file already exists, throw an error instead of waiting for bpf_obj_pin() to throw an error
- Code style changes

 tools/bpf/bpftool/common.c     | 78 +++++++++++++++++++++++++++++-----
 tools/bpf/bpftool/iter.c       |  2 +-
 tools/bpf/bpftool/main.h       |  3 +-
 tools/bpf/bpftool/prog.c       |  5 ++-
 tools/bpf/bpftool/struct_ops.c |  2 +-
 5 files changed, 75 insertions(+), 15 deletions(-)
tools/bpf/bpftool/common.c +67 -11
index cc6e6aae2447..d2746681200e 100644
@@ -244,24 +244,80 @@ int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type)
 	return fd;
 }
 
-int mount_bpffs_for_pin(const char *name, bool is_dir)
+int mount_bpffs_on_dir(const char *dir_name)
 {
 	char err_str[ERR_MAX_LEN];
-	char *file;
-	char *dir;
 	int err = 0;
 
-	if (is_dir && is_bpffs(name))
+	if (is_bpffs(dir_name))
 		return err;
 
-	file = malloc(strlen(name) + 1);
-	if (!file) {
+	if (access(dir_name, F_OK) == -1) {
+		char *temp_name;
+		char *parent_name;
+
+		temp_name = malloc(strlen(dir_name) + 1);
+		if (!temp_name) {
+			p_err("mem alloc failed");
+			return -1;
+		}
+
+		strcpy(temp_name, dir_name);
+		parent_name = dirname(temp_name);
+
+		if (is_bpffs(parent_name)) {
+			/* nothing to do if already mounted */
+			free(temp_name);
+			return err;
+		}
+
+		free(temp_name);
+
+		if (block_mount) {
+			p_err("no BPF file system found, not mounting it due to --nomount option");
+			return -1;
+		}
+
+		err = mkdir(dir_name, 0700);
+		if (err) {
+			p_err("failed to create dir (%s): %s", dir_name, strerror(errno));
+			return err;
+		}
+	} else if (block_mount) {
+		p_err("no BPF file system found, not mounting it due to --nomount option");
+		return -1;
+	}
+
+	err = mnt_fs(dir_name, "bpf", err_str, ERR_MAX_LEN);
+	if (err) {
+		err_str[ERR_MAX_LEN - 1] = '\0';
+		p_err("can't mount BPF file system on given dir (%s): %s",
+		      dir_name, err_str);
+	}
+
+	return err;
+}
+
+int mount_bpffs_given_file(const char *file_name)
+{
+	char err_str[ERR_MAX_LEN];
+	char *temp_name;
+	char *dir;
+	int err = 0;
+
+	if (access(file_name, F_OK) != -1) {
+		p_err("bpf object can't be pinned since file (%s) already exists", file_name);
+		return -1;
+	}
+
+	temp_name = malloc(strlen(file_name) + 1);
+	if (!temp_name) {
 		p_err("mem alloc failed");
 		return -1;
 	}
 
-	strcpy(file, name);
-	dir = dirname(file);
+	strcpy(temp_name, file_name);
+	dir = dirname(temp_name);
 
 	if (is_bpffs(dir))
 		/* nothing to do if already mounted */
@@ -277,11 +333,11 @@ int mount_bpffs_for_pin(const char *name, bool is_dir)
 	if (err) {
 		err_str[ERR_MAX_LEN - 1] = '\0';
 		p_err("can't mount BPF file system to pin the object (%s): %s",
-		      name, err_str);
+		      file_name, err_str);
 	}
 
 out_free:
-	free(file);
+	free(temp_name);
 	return err;
 }
 
@@ -289,7 +345,7 @@ int do_pin_fd(int fd, const char *name)
 {
 	int err;
 
-	err = mount_bpffs_for_pin(name, false);
+	err = mount_bpffs_given_file(name);
 	if (err)
 		return err;
 
tools/bpf/bpftool/iter.c +1 -1
index 6b0e5202ca7a..3911563dcc60 100644
@@ -76,7 +76,7 @@ static int do_pin(int argc, char **argv)
 		goto close_obj;
 	}
 
-	err = mount_bpffs_for_pin(path, false);
+	err = mount_bpffs_given_file(path);
 	if (err)
 		goto close_link;
 
tools/bpf/bpftool/main.h +2 -1
index b8bb08d10dec..20e06ad183ec 100644
@@ -142,7 +142,8 @@ const char *get_fd_type_name(enum bpf_obj_type type);
 char *get_fdinfo(int fd, const char *key);
 int open_obj_pinned(const char *path, bool quiet);
 int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type);
-int mount_bpffs_for_pin(const char *name, bool is_dir);
+int mount_bpffs_given_file(const char *file_name);
+int mount_bpffs_on_dir(const char *dir_name);
 int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(int *, char ***));
 int do_pin_fd(int fd, const char *name);
 
tools/bpf/bpftool/prog.c +4 -1
index 9cb42a3366c0..09b5f0415a5e 100644
@@ -1778,7 +1778,10 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
 		goto err_close_obj;
 	}
 
-	err = mount_bpffs_for_pin(pinfile, !first_prog_only);
+	if (first_prog_only)
+		err = mount_bpffs_given_file(pinfile);
+	else
+		err = mount_bpffs_on_dir(pinfile);
 	if (err)
 		goto err_close_obj;
 
tools/bpf/bpftool/struct_ops.c +1 -1
index d573f2640d8e..bf50a99b2501 100644
@@ -515,7 +515,7 @@ static int do_register(int argc, char **argv)
 	if (argc == 1)
 		linkdir = GET_ARG();
 
-	if (linkdir && mount_bpffs_for_pin(linkdir, true)) {
+	if (linkdir && mount_bpffs_on_dir(linkdir)) {
 		p_err("can't mount bpffs for pinning");
 		return -1;
 	}
Signature · 1 line
2.44.0
#1 lore raw

Thanks! Apologies for the delay.

2024-03-08 13:07 UTC+0000 ~ Sahil Siddiq <[email protected]>

Quoted 16 lines

When pinning programs/objects under PATH (eg: during "bpftool prog loadall") the bpffs is mounted on the parent dir of PATH in the following situations:
- the given dir exists but it is not bpffs.
- the given dir doesn't exist and the parent dir is not bpffs.

Mounting on the parent dir can also have the unintentional side- effect of hiding other files located under the parent dir.

If the given dir exists but is not bpffs, then the bpffs should be mounted on the given dir and not its parent dir.

Similarly, if the given dir doesn't exist and its parent dir is not bpffs, then the given dir should be created and the bpffs should be mounted on this new dir.

Quoted 7 lines
Fixes 2a36c26fe3b8 ("bpftool: Support bpffs mountpoint as pin path for prog loadall")

Note: you don't need the blank lines between the tags.

Quoted 10 lines

---
Changes since v1:
- Split "mount_bpffs_for_pin" into two functions:
- mount_bpffs_on_dir
- mount_bpffs_given_file
This is done to improve maintainability and readability.
- Improve error messages
- (mount_bpffs_given_file): If the file already exists, throw an error instead of waiting for bpf_obj_pin() to throw an error
- Code style changes

You can keep the changelog as part of the patch description.

Quoted 13 lines
 tools/bpf/bpftool/common.c     | 78 +++++++++++++++++++++++++++++-----
 tools/bpf/bpftool/iter.c       |  2 +-
 tools/bpf/bpftool/main.h       |  3 +-
 tools/bpf/bpftool/prog.c       |  5 ++-
 tools/bpf/bpftool/struct_ops.c |  2 +-
 5 files changed, 75 insertions(+), 15 deletions(-)
tools/bpf/bpftool/common.c +0 -0
index cc6e6aae2447..d2746681200e 100644

tools/bpf/bpftool/common.c int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type) · line 247

Quoted 5 lines
tools/bpf/bpftool/common.c +1 -1
@@ -244,24 +244,80 @@ int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type)
 	return fd;
 }
 
-int mount_bpffs_for_pin(const char *name, bool is_dir)
+int mount_bpffs_on_dir(const char *dir_name)

With all the checks and the potential directory creation, we could maybe rename this into "prepare_bpffs_dir()" or something like this?

Quoted 37 lines
tools/bpf/bpftool/common.c +26 -5
 {
 	char err_str[ERR_MAX_LEN];
-	char *file;
-	char *dir;
 	int err = 0;
 
-	if (is_dir && is_bpffs(name))
+	if (is_bpffs(dir_name))
 		return err;
 
-	file = malloc(strlen(name) + 1);
-	if (!file) {
+	if (access(dir_name, F_OK) == -1) {
+		char *temp_name;
+		char *parent_name;
+
+		temp_name = malloc(strlen(dir_name) + 1);
+		if (!temp_name) {
+			p_err("mem alloc failed");
+			return -1;
+		}
+
+		strcpy(temp_name, dir_name);
+		parent_name = dirname(temp_name);
+
+		if (is_bpffs(parent_name)) {
+			/* nothing to do if already mounted */
+			free(temp_name);
+			return err;
+		}
+
+		free(temp_name);
+
+		if (block_mount) {
+			p_err("no BPF file system found, not mounting it due to --nomount option");
+			return -1;
+		}

tools/bpf/bpftool/common.c int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type) · line 289

Quoted 10 lines
tools/bpf/bpftool/common.c +10 -0
+
+		err = mkdir(dir_name, 0700);
+		if (err) {
+			p_err("failed to create dir (%s): %s", dir_name, strerror(errno));
+			return err;
+		}
+	} else if (block_mount) {
+		p_err("no BPF file system found, not mounting it due to --nomount option");
+		return -1;
+	}

I'd maybe change this block a little (although it's up to you):

	bool dir_exists;

	dire_exists = (access(...) == 0);
	if (!dir_exists) {
		...
		free(temp_name);
	}

	if (block_mount) {
		...
	}

	if (!dir_exists) {
		err = mkdir(...);
		...
	}

	err = mnt_fs(...);
	...

This would also enable us to remove the directory we just created, if we're not able to mount the bpffs on it, before leaving the function.

tools/bpf/bpftool/common.c int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type) · line 301

Quoted 12 lines
tools/bpf/bpftool/common.c +12 -0
+
+	err = mnt_fs(dir_name, "bpf", err_str, ERR_MAX_LEN);
+	if (err) {
+		err_str[ERR_MAX_LEN - 1] = '\0';
+		p_err("can't mount BPF file system on given dir (%s): %s",
+		      dir_name, err_str);
+	}
+
+	return err;
+}
+
+int mount_bpffs_given_file(const char *file_name)

I'd remove/replace "given" from the name, maybe "mount_bpffs_for_file"?

tools/bpf/bpftool/common.c int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type) · line 309

Quoted 8 lines
tools/bpf/bpftool/common.c +8 -0
+{
+	char err_str[ERR_MAX_LEN];
+	char *temp_name;
+	char *dir;
+	int err = 0;
+
+	if (access(file_name, F_OK) != -1) {
+		p_err("bpf object can't be pinned since file (%s) already exists", file_name);

I'd remove "file", the existing object might be a directory and it might be confusing.

Quoted 4 lines
tools/bpf/bpftool/common.c +4 -0
+		return -1;
+	}
+
+	temp_name = malloc(strlen(file_name) + 1);

tools/bpf/bpftool/common.c int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type) · line 321

Quoted 10 lines
tools/bpf/bpftool/common.c +3 -2
+	if (!temp_name) {
 		p_err("mem alloc failed");
 		return -1;
 	}
 
-	strcpy(file, name);
-	dir = dirname(file);
+	strcpy(temp_name, file_name);
+	dir = dirname(temp_name);
 

Here, we could check for the existence of "dir", and error out otherwise. The reason is that with the current code, if dir does not exist but user passes --nomount, then we fail to pin the path (given that the directory is not present), but the message returned will be "no BPF file system found, not mounting it due to --nomount option", which is confusing.

Same note applies to the other function as well.

tools/bpf/bpftool/common.c int mount_bpffs_for_pin(const char *name, bool is_dir) · line 335

Quoted 6 lines
tools/bpf/bpftool/common.c +0 -0
 	if (is_bpffs(dir))
 		/* nothing to do if already mounted */
@@ -277,11 +333,11 @@ int mount_bpffs_for_pin(const char *name, bool is_dir)
 	if (err) {
 		err_str[ERR_MAX_LEN - 1] = '\0';
 		p_err("can't mount BPF file system to pin the object (%s): %s",

We could also indicate the path where we tried to mount the bpffs, in this message.

Quoted 67 lines
tools/bpf/bpftool/common.c +3 -3
-		      name, err_str);
+		      file_name, err_str);
 	}
 
 out_free:
-	free(file);
+	free(temp_name);
 	return err;
 }
 
@@ -289,7 +345,7 @@ int do_pin_fd(int fd, const char *name)
 {
 	int err;
 
-	err = mount_bpffs_for_pin(name, false);
+	err = mount_bpffs_given_file(name);
 	if (err)
 		return err;
 
tools/bpf/bpftool/iter.c +1 -1
index 6b0e5202ca7a..3911563dcc60 100644
@@ -76,7 +76,7 @@ static int do_pin(int argc, char **argv)
 		goto close_obj;
 	}
 
-	err = mount_bpffs_for_pin(path, false);
+	err = mount_bpffs_given_file(path);
 	if (err)
 		goto close_link;
 
tools/bpf/bpftool/main.h +2 -1
index b8bb08d10dec..20e06ad183ec 100644
@@ -142,7 +142,8 @@ const char *get_fd_type_name(enum bpf_obj_type type);
 char *get_fdinfo(int fd, const char *key);
 int open_obj_pinned(const char *path, bool quiet);
 int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type);
-int mount_bpffs_for_pin(const char *name, bool is_dir);
+int mount_bpffs_given_file(const char *file_name);
+int mount_bpffs_on_dir(const char *dir_name);
 int do_pin_any(int argc, char **argv, int (*get_fd_by_id)(int *, char ***));
 int do_pin_fd(int fd, const char *name);
 
tools/bpf/bpftool/prog.c +4 -1
index 9cb42a3366c0..09b5f0415a5e 100644
@@ -1778,7 +1778,10 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
 		goto err_close_obj;
 	}
 
-	err = mount_bpffs_for_pin(pinfile, !first_prog_only);
+	if (first_prog_only)
+		err = mount_bpffs_given_file(pinfile);
+	else
+		err = mount_bpffs_on_dir(pinfile);
 	if (err)
 		goto err_close_obj;
 
tools/bpf/bpftool/struct_ops.c +0 -0
index d573f2640d8e..bf50a99b2501 100644

tools/bpf/bpftool/struct_ops.c static int do_register(int argc, char **argv) · line 521

Quoted 8 lines
tools/bpf/bpftool/struct_ops.c +1 -1
@@ -515,7 +515,7 @@ static int do_register(int argc, char **argv)
 	if (argc == 1)
 		linkdir = GET_ARG();
 
-	if (linkdir && mount_bpffs_for_pin(linkdir, true)) {
+	if (linkdir && mount_bpffs_on_dir(linkdir)) {
 		p_err("can't mount bpffs for pinning");
 		return -1;
 	}

Other than the comments above, the patch works well, and the different cases are much easier to follow than in v1, thanks!

I've checked that the programs load as expected, the directories are created (or not) as expected, and the bpffs is mounted (or not) as expected, for all the cases I could think of, with the following commands (copied here, for the record), all worked as I expected:

mkdir -p /sys/fs/bpf/some_dir
mkdir -p /tmp/test-dir/some_dir

# /tmp/ret.o contains 1 program, /tmp/rets.o contains several ones

# Load one program under bpffs
bpftool prog load /tmp/ret.o /sys/fs/bpf/foo type xdp mount | grep bpf
ls /sys/fs/bpf/foo

# Try to load one program when pin path exists, under bpffs bpftool prog load /tmp/ret.o /sys/fs/bpf/foo type xdp mount | grep bpf
ls /sys/fs/bpf/foo
rm /sys/fs/bpf/foo

# Load one program under bpffs, with --nomount bpftool --nomount prog load /tmp/ret.o /sys/fs/bpf/foo type xdp mount | grep bpf
ls /sys/fs/bpf/foo
rm /sys/fs/bpf/foo

# Load one program outside of bpffs, with --nomount bpftool --nomount prog load /tmp/ret.o /tmp/test-dir/foo type xdp mount | grep bpf
ls /tmp/test-dir/foo
# Load one program outside of bpffs
bpftool prog load /tmp/ret.o /tmp/test-dir/foo type xdp mount | grep bpf
ls /tmp/test-dir/foo
# Try to load one program when pin path exists, outside of bpffs bpftool prog load /tmp/ret.o /tmp/test-dir/foo type xdp mount | grep bpf
rm /tmp/test-dir/foo
umount /tmp/test-dir
umount /tmp/test-dir

# Load multiple programs under bpffs, directory exists bpftool prog loadall /tmp/rets.o /sys/fs/bpf/some_dir mount | grep bpf
ls /sys/fs/bpf/some_dir
rm /sys/fs/bpf/some_dir/*
# Load multiple programs under bpffs, with -n, directory exists bpftool --nomount prog loadall /tmp/rets.o /sys/fs/bpf/some_dir mount | grep bpf
ls /sys/fs/bpf/some_dir
rm /sys/fs/bpf/some_dir/*

# Load multiple programs under bpffs, directory does not exist bpftool prog loadall /tmp/rets.o /sys/fs/bpf/new_dir mount | grep bpf
ls /sys/fs/bpf/new_dir
rm -r /sys/fs/bpf/new_dir
# Load multiple progs under bpffs, with -n, directory doesn't exist bpftool --nomount prog loadall /tmp/rets.o /sys/fs/bpf/new_dir mount | grep bpf
ls /sys/fs/bpf/new_dir
rm -r /sys/fs/bpf/new_dir

# Load multiple programs outside of bpffs, directory exists bpftool prog loadall /tmp/rets.o /tmp/test-dir/some_dir mount | grep bpf
ls /tmp/test-dir/some_dir
rm /tmp/test-dir/some_dir/*
umount /tmp/test-dir/some_dir
umount /tmp/test-dir/some_dir
# Try to load multiple progs outside of bpffs, with -n, dir exists bpftool --nomount prog loadall /tmp/rets.o /tmp/test-dir/some_dir mount | grep bpf
ls /tmp/test-dir/some_dir

# Load multiple programs outside of bpffs, directory does not exist bpftool prog loadall /tmp/rets.o /tmp/test-dir/new_dir mount | grep bpf
ls /tmp/test-dir/new_dir
umount /tmp/test-dir/new_dir
umount /tmp/test-dir/new_dir
rm -r /tmp/test-dir/new_dir
# Try to load multiple progs outside of bpffs, with -n, new dir bpftool --nomount prog loadall /tmp/rets.o /tmp/test-dir/new_dir mount | grep bpf
ls /tmp/test-dir/new_dir
rm -r /tmp/test-dir

Thanks,
Quentin

author
#2 lore raw

Hi,

Quoted 1 line · IST Quentin Monnet

Thanks! Apologies for the delay.

No worries! Thank you for the review.

Quoted 4 lines

[...]
Note: you don't need the blank lines between the tags. [...]
You can keep the changelog as part of the patch description.

Got it. I'll keep this in mind when I submit v3.

Quoted 3 lines

[...]
With all the checks and the potential directory creation, we could maybe rename this into "prepare_bpffs_dir()" or something like this?

"prepare_bpffs_dir" is quite apt. If longer names are acceptable then I would also recommend "prepare_and_mount_bpffs_dir" so it indicates that it'll also mount the bpffs on the dir (when relevant) after performing the checks.

Quoted 23 lines

[...]
I'd maybe change this block a little (although it's up to you):

	bool dir_exists;

	dire_exists = (access(...) == 0);
	if (!dir_exists) {
		...
		free(temp_name);
	}

	if (block_mount) {
		...
	}

	if (!dir_exists) {
		err = mkdir(...);
		...
	}

	err = mnt_fs(...);
	...
Quoted 2 lines

This would also enable us to remove the directory we just created, if we're not able to mount the bpffs on it, before leaving the function.

I agree with this. This will also keep the implementation a little more succinct with just one "block_mount" conditional block.

Quoted 2 lines

[...]
I'd remove/replace "given" from the name, maybe "mount_bpffs_for_file"?

This is definitely a better name. I am not very good when it comes to making up names :P

Quoted 37 lines

[...]
I'd remove "file", the existing object might be a directory and it might be confusing.

Quoted 5 lines
tools/bpf/bpftool/common.c +5 -0
+		return -1;
+	}
+
+	temp_name = malloc(strlen(file_name) + 1);
+	if (!temp_name) {

tools/bpf/bpftool/common.c int open_obj_pinned_any(const char *path, enum bpf_obj_type exp_type) · line 320

Quoted 10 lines
tools/bpf/bpftool/common.c +2 -2
 
 		p_err("mem alloc failed");
 		return -1;
 
 	}
 
-	strcpy(file, name);
-	dir = dirname(file);
+	strcpy(temp_name, file_name);
+	dir = dirname(temp_name);

Here, we could check for the existence of "dir", and error out otherwise. The reason is that with the current code, if dir does not exist but user passes --nomount, then we fail to pin the path (given that the directory is not present), but the message returned will be "no BPF file system found, not mounting it due to --nomount option", which is confusing.

Same note applies to the other function as well.

Quoted 8 lines
tools/bpf/bpftool/common.c +0 -0
 	if (is_bpffs(dir))
 
 		/* nothing to do if already mounted */
@@ -277,11 +333,11 @@ int mount_bpffs_for_pin(const char *name, bool

is_dir)>
if (err) {

Quoted 5 lines

tools/bpf/bpftool/common.c int mount_bpffs_for_pin(const char *name, bool is_dir) · line 335

Quoted 2 lines
tools/bpf/bpftool/common.c +0 -0
 		err_str[ERR_MAX_LEN - 1] = '\0';
 		p_err("can't mount BPF file system to pin the object (%s): %s",

We could also indicate the path where we tried to mount the bpffs, in this message.

Understood. I'll make these changes as well.

Quoted 8 lines

[...]
Other than the comments above, the patch works well, and the different cases are much easier to follow than in v1, thanks!

I've checked that the programs load as expected, the directories are created (or not) as expected, and the bpffs is mounted (or not) as expected, for all the cases I could think of, with the following commands (copied here, for the record), all worked as I expected:

That's really nice to hear. I'll incorporate the recommended changes and will send v3 soon.

Thanks,
Sahil

#3 lore raw

2024-03-14 21:16 UTC+0000 ~ Sahil <[email protected]>

Quoted 14 lines

Hi,

Quoted 1 line · IST Quentin Monnet

Thanks! Apologies for the delay.

No worries! Thank you for the review.

Quoted 4 lines

[...]
Note: you don't need the blank lines between the tags. [...]
You can keep the changelog as part of the patch description.

Got it. I'll keep this in mind when I submit v3.

Quoted 8 lines
Quoted 3 lines

[...]
With all the checks and the potential directory creation, we could maybe rename this into "prepare_bpffs_dir()" or something like this?

"prepare_bpffs_dir" is quite apt. If longer names are acceptable then I would also recommend "prepare_and_mount_bpffs_dir" so it indicates that it'll also mount the bpffs on the dir (when relevant) after performing the checks.

The length looks acceptable to me. I used "prepare" to summarise "create and mount", if you prefer "mount" explicitly then maybe "create_and_mount_bpffs_dir()"? There's no other preparation step as far as I remember so we should as well make it clear.

Quoted 2 lines

That's really nice to hear. I'll incorporate the recommended changes and will send v3 soon.

Thanks a lot,
Quentin

author
#4 lore raw

Hi,

Sorry for the delay in my response. I have made
the relevant changes and have sent v3.

Thanks,
Sahil