mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-04 21:03:26 +00:00
lib/bpf: Fix and simplify bpf_mnt_check_target()
As stated in commitac3415f5c1
("lib/fs: Fix and simplify make_path()"), calling stat() before mkdir() is racey, because the entry might change in between. As the call to stat() seems to only check for target existence, we can simply call mkdir() unconditionally and catch all errors but EEXIST. Fixes:95ae9a4870
("bpf: fix mnt path when from env") Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
This commit is contained in:
parent
1e25de9a92
commit
d4fcdbbec9
@ -510,20 +510,14 @@ static int bpf_mnt_fs(const char *target)
|
||||
|
||||
static int bpf_mnt_check_target(const char *target)
|
||||
{
|
||||
struct stat sb = {};
|
||||
int ret;
|
||||
|
||||
ret = stat(target, &sb);
|
||||
if (ret) {
|
||||
ret = mkdir(target, S_IRWXU);
|
||||
if (ret) {
|
||||
if (ret && errno != EEXIST)
|
||||
fprintf(stderr, "mkdir %s failed: %s\n", target,
|
||||
strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bpf_valid_mntpt(const char *mnt, unsigned long magic)
|
||||
|
Loading…
Reference in New Issue
Block a user