Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 26 May 2013, 02:57
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How can i check if sfs is loaded?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [30 Posts]   Goto page: 1, 2 Next
Author Message
RSH


Joined: 05 Sep 2011
Posts: 1564
Location: Germany

PostPosted: Fri 30 Mar 2012, 15:11    Post subject:  How can i check if sfs is loaded?  

Hi.

I do use scripts to load different sfs files on the fly - just calling sfs_load and give filename as a parameter. I now need to refine these scripts in a way to get information about if the sfs is already loaded. So i can "catch" starting of sfs_load and its unload GUI.

How can i find out, if an sfs file is already loaded, by using the filename as parameter?

I did try a suggestion by rhadon, but it didn't work. Sad
Code:
if [ "$(which LazY528-Internet.sfs)" ]; then
   echo "gefunden"
   else
   echo "nicht gefunden"
fi


This did also not work.
Code:
if [ "$(which LazY528-Internet)" ]; then
   echo "gefunden"
   else
   echo "nicht gefunden"
fi


Thanks in advance

_________________
Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
Back to top
View user's profile Send private message 
RSH


Joined: 05 Sep 2011
Posts: 1564
Location: Germany

PostPosted: Fri 30 Mar 2012, 15:36    Post subject: Re: How can i check if sfs is loaded?  

Ok, i found, that i did understand rhadon's suggestion the wrong way. He wanted me to ask for a program inside the sfs - not asking for the sfs. Embarassed

This way it works:
Code:
if [ "$(which opera)" ]; then
   echo "gefunden"
   else
   echo "nicht gefunden"
fi


Anyway - is there a way to do this like i was asking for?

_________________
Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 572

PostPosted: Fri 30 Mar 2012, 15:56    Post subject:  

Hi RSH

In /etc/rc.d/BOOTCONFIG I found a list of currently loaded .sfs files.
You might parse it in your script to get the needed info.

HTH
Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
RSH


Joined: 05 Sep 2011
Posts: 1564
Location: Germany

PostPosted: Fri 30 Mar 2012, 16:18    Post subject:  

SFR wrote:
Hi RSH

In /etc/rc.d/BOOTCONFIG I found a list of currently loaded .sfs files.
You might parse it in your script to get the needed info.

HTH
Greetings!

Oohhh jaahhhh Embarassed

ghsfuhghwrqrevftgfgee Twisted Evil

Some days ago i did post exactly this in the german forum - must have gone lost while switching between german/english reading/writing/thinking. Embarassed

Laughing Laughing Laughing Thank you very much, SFR, for leading me back to this point of already been there but lost going knowledge... Laughing Laughing Laughing

(human brains are amazing strange OS's)

_________________
Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
Back to top
View user's profile Send private message 
PANZERKOPF

Joined: 16 Dec 2009
Posts: 250
Location: Earth

PostPosted: Sat 31 Mar 2012, 11:41    Post subject:  

SFR wrote:
Hi RSH
In /etc/rc.d/BOOTCONFIG I found a list of currently loaded .sfs files.

BOOTCONFIG contains list of files mounted by initrd but RSH needs a list of manually mounted files.
Seems that is impossible to recognize a name of file being mounted as loop device. Sad

_________________
SUUM CUIQUE.
Back to top
View user's profile Send private message 
RSH


Joined: 05 Sep 2011
Posts: 1564
Location: Germany

PostPosted: Sat 31 Mar 2012, 12:50    Post subject:  

PANZERKOPF wrote:
BOOTCONFIG contains list of files mounted by initrd but RSH needs a list of manually mounted files.
Seems that is impossible to recognize a name of file being mounted as loop device. Sad

Yes, that's right. I do need a list of manually mounted sfs files.

But it is possible to do this using /etc/rc.d/BOOTCONFIG. It has an entry called LASTUNIONRECORD that contains a list of actually mounted files. If you load sfs files manually using shinobars sfs_load on-the-fly, this list will be updated after every load/unload.

I did point this out earlier in the german forum, but in differences of German/English writing/reading/thinking i forgot that fact.

So, i just did the journey twice. Embarassed Cool Laughing

Thanks to all ... Laughing

_________________
Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Sat 31 Mar 2012, 22:08    Post subject:  

There is also the command "losetup" which will give the file name for any loop number.

If you still need a way to do this I can supply the code for it.
Back to top
View user's profile Send private message 
RSH


Joined: 05 Sep 2011
Posts: 1564
Location: Germany

PostPosted: Tue 03 Apr 2012, 02:10    Post subject:  

sunburnt wrote:
There is also the command "losetup" which will give the file name for any loop number.

If you still need a way to do this I can supply the code for it.

Yes, this would be nice.

_________________
Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Fri 06 Apr 2012, 00:02    Post subject:  

Sorry about the delay, I was out of town for a few days.

This function tests if a file is loop mounted. It works with full /path/file or just part of the file name.

Usage: FileLoopMnt ( file name or /path/file )
Code:
#!/bin/sh
#########   Test if file is loop mounted.

###   Usage:   FileLoopMnt ( file name or /path/file )

FileLoopMnt() { mount |grep loop* |sed 's# .*$##' |while read N
   do losetup-FULL $N |grep $1 |sed 's#^.* .##;s#.$##' ;done ;}


FileLoopMnt $1      # Test the function.

Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 10818
Location: The Peoples Republic of California

PostPosted: Fri 06 Apr 2012, 11:31    Post subject:  

sunburnt,

I think your script is very clever.

I tested it to find a mounted file called lupu_520.sfs

The output was
/mnt/dev_save/520/lupu_520.sfs

But that path is incorrect, it should be

/initrd/mnt/dev_save/520/lupu_520.sfs


Is this what you find also?

Anyway, well done.

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
RSH


Joined: 05 Sep 2011
Posts: 1564
Location: Germany

PostPosted: Fri 06 Apr 2012, 13:13    Post subject:  

I think the difference here is the result of the different use of puppy - which means: using a save file (pupsave) or not using a save file.

I do get /mnt/sdd1/xxx.sfs, which is the right path, because i don't use any save file. If i do use a save file the path changes from /mnt/sdd1 to /mnt/home.

/mnt/home is a symbolic link to /initrd/mnt/dev_save.

This is a mean mean fact:

If you want to copy out a file of an sfs you can not use path /mnt/home on a mounted sfs file (if you want to do the copy using bash).

You have to change /mnt/home to /initrd/mnt/dev_save.

_________________
Useful Software for Puppy!
LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Fri 06 Apr 2012, 13:17    Post subject:  

Bruce B; You`re right of course.
Apparently losetup-FULL is not reliable, and neither is losetup.

Strange that a Linux command would be so horribly in error...
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 837

PostPosted: Fri 06 Apr 2012, 18:07    Post subject:  

To just check if a file is loop mounted, you could also -

Code:
[[ `losetup | grep $1` ]] && echo true


Cheers,
s
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 10818
Location: The Peoples Republic of California

PostPosted: Fri 06 Apr 2012, 18:22    Post subject:  

sunburnt, I think I think a lot more of your script than you do.

I rewrote it to correct for the missing /initrd when it should be in the output.

Also, if it is worth anything, probably not, I deleted the symlink /mnt/home a long time ago.

Code:
#filename: sunburnt
a=`mount | grep loop. | awk '{print $1}' | sort`

for i in $a ; do
losetup-FULL $i | awk '{print $1"  "$3}' | sed 's/\/mnt\/dev_save/\/initrd\/mnt\/dev_save/' 
done


# output is as below and it reflects proper path and filename for all loop devices in use.
# it is also fairly well formatted.

Code:
/dev/loop0:  (/initrd/mnt/dev_save/520/lupu_520.sfs)
/dev/loop1:  (/initrd/mnt/dev_save/520/lupusave.3fs)
/dev/loop2:  (/mnt/sda8/spotd.3fs)
/dev/loop3:  (/mnt/sda8/winehq.3fs)
/dev/loop4:  (/initrd/mnt/dev_save/520/extras.sfs)
/dev/loop5:  (/initrd/mnt/dev_save/520/lupu_devx_520.sfs)


Will you please test this script on your machine and check for consistency and accuracy?

Bruce

~

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4006
Location: Arizona, U.S.A.

PostPosted: Fri 06 Apr 2012, 23:05    Post subject:  

seaside`s is the simplest, no "mount and loop" required.
Bruce; Yes your sed command fixes this circumstance, however...

I thought of using sed to patch the bad path, but then I figured
that this error was not the only problem that losetup had going.
What if /initrd is not the only thing that`s dropped from paths?
Either a command works and is good or it`s unreliable.

I put together the code from seaside and Bruce B, Very simple now:
Code:
LoopFile() { losetup |grep $1 |sed 's#^/mnt/dev_save#/initrd/mnt/dev_save#' ;}

Last edited by sunburnt on Sat 07 Apr 2012, 00:22; edited 8 times in total
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [30 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0689s ][ Queries: 12 (0.0039s) ][ GZIP on ]