mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 03:08:51 +03:00
libzutil: import: filter out unsuitable files earlier
Only accept the right type of file, if available, and reject too-small files before opening them on Linux Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12105
This commit is contained in:
@@ -1243,10 +1243,21 @@ zpool_find_import_scan_dir(libpc_handle_t *hdl, pthread_mutex_t *lock,
|
||||
|
||||
while ((dp = readdir64(dirp)) != NULL) {
|
||||
const char *name = dp->d_name;
|
||||
if (name[0] == '.' &&
|
||||
(name[1] == 0 || (name[1] == '.' && name[2] == 0)))
|
||||
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
|
||||
continue;
|
||||
|
||||
switch (dp->d_type) {
|
||||
case DT_UNKNOWN:
|
||||
case DT_BLK:
|
||||
#ifdef __FreeBSD__
|
||||
case DT_CHR:
|
||||
#endif
|
||||
case DT_REG:
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
zpool_find_import_scan_add_slice(hdl, lock, cache, path, name,
|
||||
order);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user