guess_fstype reports unknown for Puppy SFS files. [ No Fix ]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

guess_fstype reports unknown for Puppy SFS files. [ No Fix ]

#1 Post by sunburnt »

I was looking for a new version of guess_fstype hoping to fix the problem.
Strangely I can`t seem to find it anywhere. Not SourceForge... Nowhere.

My problem is it reports "unknown" for the newer Puppy SFS files.
I could swear it use to work with the old SFS files.
I noticed that was upgraded to id ext4, so how about a fix for this problem?

I can use "file /Path/SquashFile" to detect files, but partitions still need guess_fstype.
"file" only reports "block" for partitions.

Code: Select all

	fsType=`file $PF |tr [S] [s] |egrep -o '(squashfs|ext2|ext3|ext4)'`		# image file
	[ "$fsType" = "" ]&&																						# partition
		fsType$ =`guess_fstype $PF |egrep -o '(ext2|ext3|ext4|swap|ntfs|vfat)'`
### It would obviously be nice to not have to test twice for partitions.

Is there a fix for this? Or a better way to detect partitions and image files in one command?
Last edited by sunburnt on Wed 03 Apr 2013, 22:27, edited 1 time in total.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#2 Post by seaside »

Hey Sunburnt,

You can get the source code for "guess_fstype" below mentioned in Barry's blog.
http://bkhome.org/blog2/?viewDetailed=00127

Happy St.Patricks day,
s

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

Hi seaside; Good to hear from you again.

I tried to download it, but it`s passworded so I didn`t get it.

I saw some of the ext4 fix code for it and it looked like C.
So I doubt that I`m able to do much with it.

If it`s written in Bacon and the source code`s available, I could work with that.

Most likely everyone will have to continue to use code like I posted above.

# I`m going to submit a bug report and see what happens.
.

User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#4 Post by pemasu »

u: puppy
p:linux

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#5 Post by sunburnt »

Thanks pemasu; It is C of course, so as far as fixing it I`m hobbled.

Maybe Barry or technosaurus will address the problem.

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#6 Post by Semme »

Among others, *disktype* identifies squashfs.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#7 Post by sunburnt »

Semme; Yep, I`m going to eliminate guess_fstype.

I`m looking at several alternatives, disktype looks good.

Thanks for the help! ... Terry

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#8 Post by Karl Godt »

My problem is it reports "unknown" for the newer Puppy SFS files.
I could swear it use to work with the old SFS files.
Was thinking of the new xz compression for squashfs .
But
bash-3.00# mount -o loop /JUMP-2/pup-430.sfs /mnt/loop
[18516.872500] squashfs: version 4.0 (2009/01/31) Phillip Lougher
bash-3.00# guess_fstype /dev/loop0
unknown
bash-3.00# mount
/dev/loop0 on /mnt/loop type squashfs (ro,relatime)
guess_fstype did not work on Puppy 4.3 with normal gz squash .

As far as i understand guess_fstype it is broken out of the mount(-utils) package which inludes that code as an internal function . mount-FULL guesses fstype also and in over 90% in my cases it is not necessary to specify -t whateverfs . Probably a new steal would eliminate any need for patches for the Puppy guess_fstype.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#9 Post by sunburnt »

Karl; My thought exactly, but I didn`t think the compression should matter.
Apparently my guess was correct, guess_fstype fails at old or new squash files.

In Puppy, mount and umount are scripts by Barry, I think that`s why no file system type is needed.


I`ve settled on this code to do the job in first command. It ids block devices and image files:

Code: Select all

fstype() {
FS=`disktype  $1 |tr [A-Z] [a-z] |egrep -o '(ext2|ext3|ext4|squashfs|ntfs|fat|msdos)'

[ ! "$FS" ]&& echo -e "\n###  ERROR:  Unknown file system type.\n" && exit 1

[ -f $1 ]&& Loop='-o loop '		# if file, then use loop device

case $FS in
	squashfs) FS = "squashfs -r $Loop" ;;
	fat) FS="vfat -w $Loop" ;;
	*) FS="$FS -w $Loop" ;;
esac
}

D_F=(/dev/BlockDevice or /path/ImageFile)
fs=`fstype $D_F`
[ $? -gt 0 ]&& exit

mount -t $fs $D_F MntPt$
Now watch. Technosaurus will do it all in one awk statement...

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#10 Post by Karl Godt »

and what about .iso ?

grep -iE '..|iso9660|udf'


example of a confusing disktype output:
bash-3.00# disktype /mnt/sda2/PUPPY-ISOs/FATDOG/Fatdog64-611-firefox.iso

--- /mnt/sda2/PUPPY-ISOs/FATDOG/Fatdog64-611-firefox.iso
Regular file, size 203 MiB (212860928 bytes)
DOS/MBR partition map
Partition 1: 203.0 MiB (212856832 bytes, 415736 sectors from 8, bootable)
Type 0x17 (Hidden HPFS/NTFS)
FAT16 file system (hints score 4 of 5)
Volume size 479.8 MiB (503119872 bytes, 7677 clusters of 64 KiB)
Volume name "ISOHYBRID"
ISO9660 file system
Volume name "CDROM"
Application "GENISOIMAGE ISO 9660/HFS FILESYSTEM CREATOR (C) 1993 E.YOUNGDALE (C) 1997-2006 J.PEARSON/J.SCHILLING (C) 2006-2007 CDRKIT TEAM"
Data size 202.6 MiB (212469760 bytes, 103745 blocks of 2 KiB)
El Torito boot record, catalog at 34
Bootable non-emulated image, starts at 35, preloads 2 KiB
Platform 0x00 (x86), System Type 0x00 (Empty)
ISOLINUX boot loader
Joliet extension, volume name "CDROM"
Same problem i have with udf showing iso9660 first and below udf .
I use

Code: Select all

| grep -i 'file system' | tail -n1|pipe |further

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#11 Post by jamesbond »

I used disktype in early Fatdog64 600 releases. It worked okay on my machines, but if I remember correctly there were a few feedbacks that it was rather slow on certain combination. On all of my machines, both worked equally fast, but of course YMMV.

Anyway, here is a patch for enabling squashfs detection. It works regardless of the compression types. I created the patch on guess_fs-20120911 - this version of guess_fstype isn't the latest (the latest guess_fstype from Barry's site is the one that has f2fs detection), but it is recent enough. The only caveat: The patch also contains modification for compilation with musl; so if you don't have musl and/or want to compile with dietc then you have to hack the Makefile yourself. As for whether the patch works - well, recent releases of Fatdog64 has this in it :) Compiles in both 32-bit and 64-bit systems (but not tested on ARM).

Karl Godt, disktype output of "ISO/UDF" is correct. Any ISO that also has an UDF filesystem will always be detected as iso9660 first, and then udf second. A pure-UDF filesystem (the one you do by running mkudffs) will not have any iso9660 stuff, but it cannot also be correctly described as an ISO file.

As for Fatdog64 iso (that of 610-series), it is an isohybrid which means that is is a valid ISO, but at the same time it also has a partition table to make it look like a disk image that can be flashed directly to an USB flash drive. I think amigo just made a timely related post here: http://murga-linux.com/puppy/viewtopic. ... 279#693279 (read the isohybrid part).
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#12 Post by Karl Godt »

Excellent, James ! Have applied it on http://murga-linux.com/puppy/viewtopic.php?p=651646#651646 the source ball by technosaurus with btrfs support and works fine :

/dev/loop0 on /mnt/luci-218.sfs.16570 type squashfs (ro,relatime)
./guess_fstype /dev/loop0
squashfs

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#13 Post by sunburnt »

Thanks jamesbond; Why doesn`t Barry`s new version have fixed squashfs?
Anyway, guess_fstype is Puppy specific and not in other mainstream Linux distros.

Karl; I see what you mean, my intentions for this code was mounting for app. development.
But iso is important enough, and the code could be used generally also.
I assume udf is a format inside the iso9660 wrapper?

# Wouldn`t it be nice if ALL "bash" commands had an option to output only data, no trash?


My intent is an app. to add a temp. top write layer to Puppy`s aufs layers ( a dir. ).
So installed Apps. are isolated from Puppy`s save file and can be developed normally.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#14 Post by Karl Godt »

You mean something like forcing PUPMODE=13 on USB-Flash on frugal HDD installations PUPMODE=12 ?

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#15 Post by sunburnt »

I don`t know the pup-modes, I do know flash-mode does a timed save.

Thinking a new top union layer in Puppy`s aufs, or a fuse-union on top of aufs /.
So aufs = mainSFS | saveSFS on / , and then fuse = dir. on / .

I like the idea of using fuse as it`s easy to setup for most distros.
And it`s only for app. development, not a permanent part of the O.S.
Last edited by sunburnt on Fri 22 Mar 2013, 05:29, edited 1 time in total.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#16 Post by Karl Godt »

Then I would try to create a second temporary folder
ie

Code: Select all

mkdir /tmp_APP
mount -t tmpfs none /tmp_APP
cd /tmp_APP
(( execute my needs here ))
Or is it important that it is on top layer ?

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#17 Post by sunburnt »

It could be a lower layer and apps. are then added through the mount point.

But it has to be mounted on / or chroot is needed for the app. to run normally.

That`s the whole idea is to install apps. to a separate layer to keep Save clean.
And then to build up the app. and be able to run it for testing.


So: unionfs-fuse -o nonempty $AppDir=RW:/=RO /

I think it`ll work, but maybe not...

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#18 Post by Karl Godt »

So you want tho mount the same puppy.sfs and devx.sfs on another mountpoint read-write to chroot into it,
create the application,
unmount these both .sfs
so only the application files and directories remain in the merged mountpoint,
run dir2sfs onto the mountpoint ,
[ mv the created application.sfs to a secure place ]
and finally unmount the main mountpoint .

A simple attempt by me would look like:

Puppy's filemnt had been a little stupid and refused to mount the same pup-xxx.sfs another time, but npierce had submitted a patch to use stat that was merged upstream and nowerdays that should be possible to mount pup-xxx.sfs and devx-xxx.sfs, copy their contents into the main mountpoint so the needed tools would be available when chroot ing into the main mountpoint. But that would need another free RAM of at least 1GB and more .
[/simple attempt]

To merge .sfs 'es, as it is done by Puppy, I would need to look into /init or shinobar's sfs_load to know how this exactly works with he mount option(s) . That would need only 250MB of free RAM i think.

Thierry, your idea is quite good to create a pristine environment without booting PUPPY to RAM, creating an application.2fs save-file, booting another time to load the devx by bootmanager and booting a third time so the environment finally is created.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#19 Post by sunburnt »

Karl; The code scrap I showed is how to make a fuse union on /.
Some extra options may be needed to get it working:

Code: Select all

unionfs-fuse -o  cow,allow_other,dev,nonempty $AppDir=RW:/=RO /
I see no reason it wouldn`t work over the top of aufs, in fact I`ve got it to work.
I have several apps. running no-union, fuse + chroot from AppDir style pkgs in Puppy.
The only difference is the union moint point is a dir. and not /.
Unioned on / means that chroot is not needed I think, / is already /.
I think the existing / being mounted as the bottom layer assures it will be visible.

UPDATE: Tried a test and it mounted without errors, but the unioned dir. doesn`t show.

Code: Select all

unionfs-fuse -o cow,allow_other,dev,nonempty /root/0=RW:/=RO /
"mount" shows the fuse union on /, but dirs. /A and /B in /root/0 don`t show in /.

Code: Select all

unionfs-fuse on / type fuse.unionfs-fuse (rw,nosuid,relatime,user_id=0,group_id=0,default_permissions,allow_other)
# ALSO: Tried "union & chroot" on /tmp/mnt/chroot, works of course.
Copied audacious to it and most of it shows, but /usr/lib became unaccessable.
This is pretty typical of trying to use chroot in Puppy, it`s damn unreliable.

If it won`t work, a new top layer can always be added to Puppy`s aufs union.
This is the easy way to do it and sure to work, but not good for other distros.


Unfortunately sfs_load only unions sfs files in aufs, not image files ( why? ),
I asked shinobar to add loading ext2, ext3, ext4, and btrfs image files also.

No word from shinobar, so I`m writing a general purpose fuse GUI tool in Bacon.
I guess it could check for aufs and use it, if no aufs then use unionfs-fuse.
.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#20 Post by sunburnt »

Karl; I settled on a simpler solution that I had I rejected earlier.

Linux seems to have no way to get dir.-file creation times, only modification.
So... Take a snap-shot of selected dirs., do the install and run the app.
Then take another snap-shot and list the added paths and files.

The GUI script I wrote was surprisingly simple and small.
It has a list variable for the selected dirs.: /etc, /var, /opt, /usr, $HOME

It`s a simple wizard type of GUI app.

1) It starts with an xmessage to take the first snap-shot.

2) A second xmessage pauses for installing the app.
... Install and run the app. so the app. creates it`s needed paths and files.

3) Then click the xmessage for the second snap-shot.
... A file is made of the paths and files the installed app. added to the selected dirs.

4) A third xmessage asks to remove the new paths and files ( uninstall the app.).

So for each app. that`s installed and run, a file named for the app. is
created that lists all paths and files that the app. adds to the selected dirs.

This is much simpler than messing with unions and chroot, and
it will work with any Linux O.S. no matter what type of install it is.

# Karl... Tell me what you think... Terry
.

Post Reply