mount-util: add name_to_handle_at_loop() wrapper around name_to_handle_at()
As it turns out MAX_HANDLE_SZ is a lie, the handle buffer we pass into name_to_handle_at() might need to be larger than MAX_HANDLE_SZ, and we thus need to invoke name_to_handle_at() in a loop, growing the buffer as needed. This adds a new wrapper name_to_handle_at_loop() around name_to_handle_at() that does the necessary looping, and ports over all users. Fixes: #7082
This commit is contained in:
@@ -346,16 +346,14 @@ static bool unix_socket_alive(const char *fn) {
|
||||
|
||||
static int dir_is_mount_point(DIR *d, const char *subdir) {
|
||||
|
||||
union file_handle_union h = FILE_HANDLE_INIT;
|
||||
int mount_id_parent, mount_id;
|
||||
int r_p, r;
|
||||
|
||||
r_p = name_to_handle_at(dirfd(d), ".", &h.handle, &mount_id_parent, 0);
|
||||
r_p = name_to_handle_at_loop(dirfd(d), ".", NULL, &mount_id_parent, 0);
|
||||
if (r_p < 0)
|
||||
r_p = -errno;
|
||||
|
||||
h.handle.handle_bytes = MAX_HANDLE_SZ;
|
||||
r = name_to_handle_at(dirfd(d), subdir, &h.handle, &mount_id, 0);
|
||||
r = name_to_handle_at_loop(dirfd(d), subdir, NULL, &mount_id, 0);
|
||||
if (r < 0)
|
||||
r = -errno;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user