LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-15-2011, 09:24 PM   #1
hello.freeman
Member
 
Registered: Apr 2010
Posts: 38

Rep: Reputation: 23
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:
 
Old 03-16-2011, 06:22 AM   #2
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
Submit your patch to Alien Bob for consideration.
 
1 members found this post helpful.
Old 03-16-2011, 07:26 PM   #3
hello.freeman
Member
 
Registered: Apr 2010
Posts: 38

Original Poster
Rep: Reputation: 23
Quote:
Originally Posted by Bruce Hill View Post
Submit your patch to Alien Bob for consideration.
I don't know who maintain the script before now.
I'll do it later.
thanks.
 
Old 03-16-2011, 07:46 PM   #4
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,661

Rep: Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784
I think it's AlienBOB
You can find his contact from his blog: http://alien.slackbook.org/blog/
 
Old 03-16-2011, 10:18 PM   #5
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
Quote:
Originally Posted by willysr View Post
I think it's AlienBOB
You can find his contact from his blog: http://alien.slackbook.org/blog/
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.
 
Old 03-17-2011, 06:02 AM   #6
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,896

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
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
 
Old 03-17-2011, 08:45 AM   #7
+Alan Hicks+
Member
 
Registered: Feb 2005
Distribution: Slackware
Posts: 72

Rep: Reputation: 55
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?
 
Old 03-17-2011, 12:54 PM   #8
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,896

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
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.
 
Old 03-17-2011, 02:33 PM   #9
Darth Vader
Senior Member
 
Registered: May 2008
Location: Romania
Distribution: DARKSTAR Linux 2008.1
Posts: 2,727

Rep: Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247Reputation: 1247
BTW, those changes are tested on a real initrd? With BusyBox tools?

We known that the BusyBox utilities sometimes works slighty different...
 
Old 03-17-2011, 02:47 PM   #10
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,896

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware-current: mkinitrd -c -m ahci:ext3 -k 2.6.36.1 failure burdi01 Slackware 10 12-28-2010 02:22 PM
script error in mkinitrd with -current bonaire Slackware 7 05-09-2010 06:23 AM
Slackware-current and mkinitrd-1.3.2 prontxo Slackware 4 04-11-2008 11:18 AM
Slackware-current and mkinitrd-1.3.1 prontxo Slackware 8 03-30-2008 06:43 AM
mkinitrd script with slackware deb75 Slackware 1 04-20-2004 10:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration