Slackware This Forum is for the discussion of Slackware Linux.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
03-15-2011, 09:24 PM
#1
Member
Registered: Apr 2010
Posts: 38
Rep:
a patch to script 'init' which in mkinitrd-1.4.6-i486-5 - slackware-current
Make the code work when RESUMEDEV is a symbolic link which has a relative path.
Code:
diff -Naur initrd-tree-orig/init initrd-tree-new/init
--- initrd-tree-orig/init 2011-03-13 23:41:35.000000000 +0000
+++ initrd-tree-new/init 2011-03-16 02:03:42.990812427 +0000
@@ -260,12 +260,16 @@
# Resume state from swap
if [ "$RESUMEDEV" != "" ]; then
+ OLDCWD="$(pwd)"
if ls -l $RESUMEDEV | grep -q "^l" ; then
+ cd "$(dirname "$RESUMEDEV")"
RESUMEDEV=$(ls -l $RESUMEDEV | awk '{ print $NF }')
fi
echo "Trying to resume from $RESUMEDEV"
RESMAJMIN=$(ls -l $RESUMEDEV | tr , : | awk '{ print $5$6 }')
echo $RESMAJMIN > /sys/power/resume
+ cd "$OLDCWD"
+ unset OLDCWD
fi
# Switch to real root partition:
03-16-2011, 06:22 AM
#2
HCL Maintainer
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940
Rep:
Submit your patch to Alien Bob for consideration.
1 members found this post helpful.
03-16-2011, 07:26 PM
#3
Member
Registered: Apr 2010
Posts: 38
Original Poster
Rep:
Quote:
Originally Posted by
Bruce Hill
Submit your patch to Alien Bob for consideration.
I don't know who maintain the script before now.
I'll do it later.
thanks.
03-16-2011, 07:46 PM
#4
Senior Member
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,661
I think it's AlienBOB
You can find his contact from his blog:
http://alien.slackbook.org/blog/
03-16-2011, 10:18 PM
#5
HCL Maintainer
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940
Rep:
Quote:
Originally Posted by
willysr
Alien Bob
Or go straight to the top:
volkerdi
willy, on LQ we'd post the LQ username.
hello.freeman,
Pat Volkerding's email is posted in many Slackware files.
03-17-2011, 06:02 AM
#6
LQ Veteran
Registered: May 2008
Posts: 6,896
edit: deleted the last one as I think you can simplify further. (no need for all the readlink stuff)
Code:
printf '%d:%d\n' $(stat -L -c '0x%t 0x%T' $RESUMEDEV) >/sys/power/resume
looks like it ought to do the job.
Last edited by GazL; 03-17-2011 at 12:14 PM .
Reason: improved
03-17-2011, 08:45 AM
#7
Member
Registered: Feb 2005
Distribution: Slackware
Posts: 72
Rep:
I fail to see precisely how this changes anything at all. For example:
Code:
alan@darkstar:~$ cd /home/alan
alan@darkstar:~$ mkdir /home/alan/bar
alan@darkstar:~$ ln -s /dev/../dev/../dev/sda2 /home/alan/foo
alan@darkstar:~$ ls -l foo
lrwxrwxrwx 1 alan users 23 Mar 17 09:41 foo -> /dev/../dev/../dev/sda2
export RESUMEDEV=/home/alan/foo
Now let's see what happens when running the current init.
Code:
alan@darkstar:~$ if [ "$RESUMEDEV" != "" ]; then
> OLDCWD="$(pwd)"
> if ls -l $RESUMEDEV | grep -q "^l" ; then
> #cd "$(dirname "$RESUMEDEV")"
> RESUMEDEV=$(ls -l $RESUMEDEV | awk '{ print $NF }')
> fi
> echo "Trying to resume from $RESUMEDEV"
> RESMAJMIN=$(ls -l $RESUMEDEV | tr , : | awk '{ print $5$6 }')
> echo $RESMAJMIN
> fi
Trying to resume from /dev/../dev/../dev/sda2
8:2
Now let's look at it with your patch.
Code:
alan@darkstar:~$ if [ "$RESUMEDEV" != "" ]; then
> OLDCWD="$(pwd)"
> if ls -l $RESUMEDEV | grep -q "^l" ; then
> cd "$(dirname "$RESUMEDEV")"
> RESUMEDEV=$(ls -l $RESUMEDEV | awk '{ print $NF }')
> fi
> echo "Trying to resume from $RESUMEDEV"
> RESMAJMIN=$(ls -l $RESUMEDEV | tr , : | awk '{ print $5$6 }')
> echo $RESMAJMIN
> fi
Trying to resume from /dev/../dev/../dev/sda2
8:2
So how exactly does your patch actually fix anything at all?
03-17-2011, 12:54 PM
#8
LQ Veteran
Registered: May 2008
Posts: 6,896
Perhaps this demonstrates what (s)he's getting at:
Code:
gazl@slack:/$ ls -ld /dev/wibble
lrwxrwxrwx 1 root root 6 Mar 17 16:19 /dev/wibble -> ./sda1
gazl@slack:/$ ls -ld /dev/sda1
brw-rw---- 1 root disk 8, 1 Mar 17 16:06 /dev/sda1
gazl@slack:/$ RESUMEDEV='/dev/wibble'
gazl@slack:/$ RESUMEDEV=$(ls -l $RESUMEDEV | awk '{ print $NF }')
gazl@slack:/$ RESMAJMIN=$(ls -l $RESUMEDEV | tr , : | awk '{ print $5$6 }')
ls: cannot access ./sda1: No such file or directory
gazl@slack:/$ echo $RESMAJMIN
gazl@slack:/$
Now, with the printf/stat I came up with above we still obtain the correct major:minor numbers rather than getting a file not found.
Code:
gazl@slack;/$ RESUMEDEV='/dev/wibble'
gazl@slack:/$ printf '%d:%d\n' $(stat -L -c '0x%t 0x%T' $RESUMEDEV)
8:1
Not only is my code shorter, it appears to correctly handle relative symlinks better.
I think the change the OP suggested does the same thing but relies on changing directory in order to get the appropriate result:
Code:
gazl@slack:/$ cd /dev
gazl@slack:/dev$ RESUMEDEV=$(ls -l $RESUMEDEV | awk '{ print $NF }')
gazl@slack:/dev$ RESMAJMIN=$(ls -l $RESUMEDEV | tr , : | awk '{ print $5$6 }')
gazl@slack:/dev$ echo $RESMAJMIN
8:1
Last edited by GazL; 03-17-2011 at 12:57 PM .
03-17-2011, 02:33 PM
#9
Senior Member
Registered: May 2008
Location: Romania
Distribution: DARKSTAR Linux 2008.1
Posts: 2,727
BTW, those changes are tested on a real initrd? With BusyBox tools?
We known that the BusyBox utilities sometimes works slighty different...
03-17-2011, 02:47 PM
#10
LQ Veteran
Registered: May 2008
Posts: 6,896
I've not tried running it in an actual real initrd because I don't use resume, but I have confirmed that the busybox versions of printf and stat commands work as expected.
I don't really care about this issue, I just posted because I saw the ls -l | grep "^l" | awk.... stuff and thought: there must be a better way than that!
All times are GMT -5. The time now is 12:27 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News