init: support device of major:minor:offset format
RFC v2 1/1 init: support device of major:minor:offset format
Distribution like Ubuntu uses klibc rather than uswsusp to resume system from hibernation, which will treat 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 restoring. However in current implementation, 8:3:0 will be treated as an invalid device format, and it is found that manual resumming from hibernation will fail on lastest kernel.
This patch adds support for device with major:minor:offset format when resumming from hibernation.
--- init/do_mounts.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
init/do_mounts.c +4 -2
@@ -225,10 +225,12 @@ 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;
Signature · 1 line
1.9.1
Quoted 6 lines · Chen Yu
Distribution like Ubuntu uses klibc rather than uswsusp to resume system from hibernation, which will treat 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/resumefor manually restoring. However in current implementation, 8:3:0 will be treated as an invalid
Why can't klibc write the same information as uswsusp? Why should the kernel adapt to a specific piece of userspace?
Quoted 2 lines
device format, and it is found that manual resumming from hibernation will fail on lastest kernel.
Is this a regression, perhaps introduced by commit 283e7ad024115571 ("init: stricter checking of major:minor root= values")? If that is the case, please say so.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi, Geert
Quoted 9 lines · Geert Uytterhoeven
Quoted 6 lines · Chen Yu
Distribution like Ubuntu uses klibc rather than uswsusp to resume system from hibernation, which will treat 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/resumefor manually restoring. However in current implementation, 8:3:0 will be treated as an invalidWhy can't klibc write the same information as uswsusp?
I agree. However it seems that klibc treats all device/file as such fixed format when dealing with hibernation, I guess that might be easier for it to implement?
Quoted 9 lines
Why should the kernel adapt to a specific piece of userspace?
Quoted 2 lines
device format, and it is found that manual resumming from hibernation will fail on lastest kernel.
Is this a regression, perhaps introduced by commit
283e7ad024115571("init: stricter checking of major:minor root= values")? If that is the case, please say so.
yes, it is. I think there's a modified patch for it at:
Thanks
Best Regards,
Yu
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 24 lines · Yu Chen
Quoted 11 lines · Geert Uytterhoeven
Quoted 7 lines · Chen Yu
Distribution like Ubuntu uses klibc rather than uswsusp to resume system from hibernation, which will treat 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/resumefor manually restoring. However in current implementation, 8:3:0 will be treated as an invalidQuoted 1 line
Why can't klibc write the same information as uswsusp?
I agree. However it seems that klibc treats all device/file as such fixed format when dealing with hibernation, I guess that might be easier for it to implement?
Quoted 6 lines
Why should the kernel adapt to a specific piece of userspace?
Quoted 2 lines
device format, and it is found that manual resumming from hibernation will fail on lastest kernel.
Quoted 8 lines
Quoted 5 lines
Is this a regression, perhaps introduced by commit
283e7ad024115571("init: stricter checking of major:minor root= values")? If that is the case,
please say so.yes, it is. I think there's a modified patch for it at:
OK, thanks!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds