mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 11:19:32 +03:00
Rework zpool import excluded devices check
Current zpool import code skips directory entries which have prefixes similar to some system files on linux such as "fd", "core" etc. However, this means one cannot have one's zpools hosted inside files which are named e.g. core-1 or lp. Furthermore, apart from the string checks there is already which makes the zpool_open_func work only with regular files and block devices. To fix this problem remove most of the checks since they are redundant but leave the checks for the 'hpet' and 'watchdog' names. Furthermore, change the checks to strcmp which albeit less safe than strncmp allows to have devices whose names are prefixed by 'hpet' or 'watchdog'. Signed-off-by: Nikolay Borisov <kernel@kyup.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4438
This commit is contained in:
parent
98f03691a4
commit
8fc5674c52
@ -1353,6 +1353,20 @@ check_slices(avl_tree_t *r, int fd, const char *sname)
|
||||
#endif
|
||||
}
|
||||
|
||||
static boolean_t
|
||||
is_watchdog_dev(char *dev)
|
||||
{
|
||||
/* For 'watchdog' dev */
|
||||
if (strcmp(dev, "watchdog") == 0)
|
||||
return (B_TRUE);
|
||||
|
||||
/* For 'watchdog<digit><whatever> */
|
||||
if (strstr(dev, "watchdog") == dev && isdigit(dev[8]))
|
||||
return (B_TRUE);
|
||||
|
||||
return (B_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
zpool_open_func(void *arg)
|
||||
{
|
||||
@ -1369,35 +1383,11 @@ zpool_open_func(void *arg)
|
||||
* Skip devices with well known prefixes there can be side effects
|
||||
* when opening devices which need to be avoided.
|
||||
*
|
||||
* core - Symlink to /proc/kcore
|
||||
* fd* - Floppy interface.
|
||||
* fuse - Fuse control device.
|
||||
* hpet - High Precision Event Timer
|
||||
* lp* - Printer interface.
|
||||
* parport* - Parallel port interface.
|
||||
* ppp - Generic PPP driver.
|
||||
* random - Random device
|
||||
* rtc - Real Time Clock
|
||||
* tty* - Generic serial interface.
|
||||
* urandom - Random device.
|
||||
* usbmon* - USB IO monitor.
|
||||
* vcs* - Virtual console memory.
|
||||
* watchdog - Watchdog must be closed in a special way.
|
||||
*/
|
||||
if ((strncmp(rn->rn_name, "core", 4) == 0) ||
|
||||
(strncmp(rn->rn_name, "fd", 2) == 0) ||
|
||||
(strncmp(rn->rn_name, "fuse", 4) == 0) ||
|
||||
(strncmp(rn->rn_name, "hpet", 4) == 0) ||
|
||||
(strncmp(rn->rn_name, "lp", 2) == 0) ||
|
||||
(strncmp(rn->rn_name, "parport", 7) == 0) ||
|
||||
(strncmp(rn->rn_name, "ppp", 3) == 0) ||
|
||||
(strncmp(rn->rn_name, "random", 6) == 0) ||
|
||||
(strncmp(rn->rn_name, "rtc", 3) == 0) ||
|
||||
(strncmp(rn->rn_name, "tty", 3) == 0) ||
|
||||
(strncmp(rn->rn_name, "urandom", 7) == 0) ||
|
||||
(strncmp(rn->rn_name, "usbmon", 6) == 0) ||
|
||||
(strncmp(rn->rn_name, "vcs", 3) == 0) ||
|
||||
(strncmp(rn->rn_name, "watchdog", 8) == 0))
|
||||
if ((strcmp(rn->rn_name, "hpet") == 0) ||
|
||||
is_watchdog_dev(rn->rn_name))
|
||||
return;
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user