Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
init: fix regression by supporting devices with major:minor:offset fo…
Browse files Browse the repository at this point in the history
…rmat

Commit 283e7ad ("init: stricter checking of major:minor root=
values") was so strict that it exposed the fact that a previously
unknown device format was being used.

Distributions like Ubuntu uses klibc (rather than uswsusp) to resume
system from hibernation.  klibc expressed the swap partition/file in
the form of major:minor:offset.  For example, 8:3:0 represents a swap
partition in klibc, and klibc's resume process in initrd will finally
echo 8:3:0 to /sys/power/resume for manually resuming.  However, due
to commit 283e7ad's stricter checking, 8:3:0 will be treated as an
invalid device format, and manual resuming from hibernation will fail.

Fix this by adding support for devices with major:minor:offset format
when resuming from hibernation.

Reported-by: Prigent, Christophe <christophe.prigent@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
yu-chen-surf authored and snitm committed May 5, 2015
1 parent c0403ec commit cb31ef4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions init/do_mounts.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ dev_t name_to_dev_t(const char *name)
#endif

if (strncmp(name, "/dev/", 5) != 0) {
unsigned maj, min;
unsigned maj, min, offset;
char dummy;

if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) {
if ((sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2) ||
(sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset, &dummy) == 3)) {
res = MKDEV(maj, min);
if (maj != MAJOR(res) || min != MINOR(res))
goto fail;
Expand Down

0 comments on commit cb31ef4

Please sign in to comment.