Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:Update
mdadm.5365
0019-util-split-get_maj_min-out-from-dev_open.p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0019-util-split-get_maj_min-out-from-dev_open.patch of Package mdadm.5365
From cc742d38071c631311309b68b51f8938cdf916be Mon Sep 17 00:00:00 2001 From: NeilBrown <neilb@suse.de> Date: Mon, 11 Aug 2014 10:27:31 +1000 Subject: [PATCH 026/359] util: split get_maj_min() out from dev_open() References: bsc#1081910 This allows other code to parse "8:3" style device names. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Coly Li <colyli@suse.de> --- mdadm.h | 1 + util.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/mdadm.h b/mdadm.h index dc3c107..fc1fd31 100644 --- a/mdadm.h +++ b/mdadm.h @@ -1283,6 +1283,7 @@ extern int check_partitions(int fd, char *dname, unsigned long long size); extern int get_mdp_major(void); +extern int get_maj_min(char *dev, int *major, int *minor); extern int dev_open(char *dev, int flags); extern int open_dev(char *devnm); extern void reopen_mddev(int mdfd); diff --git a/util.c b/util.c index 7937eb6..37c6e0d 100644 --- a/util.c +++ b/util.c @@ -871,12 +871,20 @@ void put_md_name(char *name) } #endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */ +int get_maj_min(char *dev, int *major, int *minor) +{ + char *e; + *major = strtoul(dev, &e, 0); + return (e > dev && *e == ':' && e[1] && + (*minor = strtoul(e+1, &e, 0)) >= 0 && + *e == 0); +} + int dev_open(char *dev, int flags) { /* like 'open', but if 'dev' matches %d:%d, create a temp * block device and open that */ - char *e; int fd = -1; char devname[32]; int major; @@ -885,10 +893,7 @@ int dev_open(char *dev, int flags) if (!dev) return -1; flags |= O_DIRECT; - major = strtoul(dev, &e, 0); - if (e > dev && *e == ':' && e[1] && - (minor = strtoul(e+1, &e, 0)) >= 0 && - *e == 0) { + if (get_maj_min(dev, &major, &minor)) { snprintf(devname, sizeof(devname), "/dev/.tmp.md.%d:%d:%d", (int)getpid(), major, minor); if (mknod(devname, S_IFBLK|0600, makedev(major, minor)) == 0) { -- 2.16.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor