From: YunQiang Su Date: Tue, 25 Dec 2018 11:01:17 +0000 (+0800) Subject: Pass seperate dev_t var to device_path_parse_major_minor X-Git-Tag: archive/raspbian/240-2+rpi1^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9f39a290e2498a7e86682d2f09672b20339687fd;p=systemd.git Pass seperate dev_t var to device_path_parse_major_minor MIPS/O32's st_rdev member of struct stat is unsigned long, which is 32bit, while dev_t is defined as 64bit, which make some problems in device_path_parse_major_minor. Don't pass st.st_rdev to device_path_parse_major_minor, while pass a seperate var, and then assign into struct stat. Gbp-Pq: Topic debian Gbp-Pq: Name Pass-seperate-dev_t-var-to-device_path_parse_major_minor.patch --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index a7ce3fce..1e0bfd8c 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -397,17 +397,20 @@ static void cgroup_xattr_apply(Unit *u) { static int lookup_block_device(const char *p, dev_t *ret) { struct stat st = {}; + dev_t st_rdev; int r; assert(p); assert(ret); - r = device_path_parse_major_minor(p, &st.st_mode, &st.st_rdev); + r = device_path_parse_major_minor(p, &st.st_mode, &st_rdev); if (r == -ENODEV) { /* not a parsable device node, need to go to disk */ if (stat(p, &st) < 0) return log_warning_errno(errno, "Couldn't stat device '%s': %m", p); } else if (r < 0) return log_warning_errno(r, "Failed to parse major/minor from path '%s': %m", p); + else + st.st_rdev = (__typeof__ (st.st_rdev))st_rdev; if (S_ISCHR(st.st_mode)) { log_warning("Device node '%s' is a character device, but block device needed.", p); @@ -437,6 +440,7 @@ static int lookup_block_device(const char *p, dev_t *ret) { static int whitelist_device(BPFProgram *prog, const char *path, const char *node, const char *acc) { struct stat st = {}; + dev_t st_rdev; int r; assert(path); @@ -445,7 +449,7 @@ static int whitelist_device(BPFProgram *prog, const char *path, const char *node /* Some special handling for /dev/block/%u:%u, /dev/char/%u:%u, /run/systemd/inaccessible/chr and * /run/systemd/inaccessible/blk paths. Instead of stat()ing these we parse out the major/minor directly. This * means clients can use these path without the device node actually around */ - r = device_path_parse_major_minor(node, &st.st_mode, &st.st_rdev); + r = device_path_parse_major_minor(node, &st.st_mode, &st_rdev); if (r < 0) { if (r != -ENODEV) return log_warning_errno(r, "Couldn't parse major/minor from device path '%s': %m", node); @@ -457,7 +461,8 @@ static int whitelist_device(BPFProgram *prog, const char *path, const char *node log_warning("%s is not a device.", node); return -ENODEV; } - } + } else + st.st_rdev = (__typeof__ (st.st_rdev))st_rdev; if (cg_all_unified() > 0) { if (!prog)