diff options
author | lulf <lulf@FreeBSD.org> | 2009-04-10 09:13:58 +0000 |
---|---|---|
committer | lulf <lulf@FreeBSD.org> | 2009-04-10 09:13:58 +0000 |
commit | e13cab7798a19e15641e32a844874e969c83c7eb (patch) | |
tree | aea2b7f8db8f6717d45bb68e25e066699ef8fa9e /sbin | |
parent | 62687638dfa1347290a308e562153a2314cbd8fa (diff) | |
download | FreeBSD-src-e13cab7798a19e15641e32a844874e969c83c7eb.zip FreeBSD-src-e13cab7798a19e15641e32a844874e969c83c7eb.tar.gz |
- Move logic for finding a unique drive name into its own routine for future
code reuse.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/gvinum/gvinum.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sbin/gvinum/gvinum.c b/sbin/gvinum/gvinum.c index b867fd4..81bdbe4 100644 --- a/sbin/gvinum/gvinum.c +++ b/sbin/gvinum/gvinum.c @@ -82,6 +82,7 @@ void printconfig(FILE *, char *); char *create_drive(char *); void create_volume(int, char **, char *); char *find_name(const char *, int, int); +char *find_drive(const char *); char *find_pattern(char *, char *); int @@ -422,11 +423,7 @@ create_drive(char *device) drives = 1; dname = NULL; - /* Strip away eventual /dev/ in front. */ - if (strncmp(device, "/dev/", 5) == 0) - device += 5; - - drivename = find_name("gvinumdrive", GV_TYPE_DRIVE, GV_MAXDRIVENAME); + drivename = find_drive(device); if (drivename == NULL) return (NULL); @@ -628,6 +625,16 @@ find_name(const char *prefix, int type, int namelen) return (NULL); } +char * +find_drive(const char *device) +{ + + /* Strip away eventual /dev/ in front. */ + if (strncmp(device, "/dev/", 5) == 0) + device += 5; + return (find_name("gvinumdrive", GV_TYPE_DRIVE, GV_MAXDRIVENAME)); +} + /* Detach a plex or subdisk from its parent. */ void gvinum_detach(int argc, char **argv) |