lkml.org 
[lkml]   [1996]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: Any "file" utility for partitions?
On Tue, 26 Mar 1996, Bjorn Ekwall wrote:

> Hi all!
>
> For now one can recognize a (Linux) swap-partition by looking for
> the swap signature as well as identify quite a few other types
> by looking for the (respective) s_magic fields in the super blocks.
>
> So, has anyone created such a tool (yet)? Any takers?
>
Played around a bit, and found a relativ simple way to identify all my
ext2-partitions:

First, I hacked the file (3.15) utility a bit to look at block specials
files too:

----------------------------
--- fsmagic.c-orig Wed Mar 27 21:13:26 1996
+++ fsmagic.c Wed Mar 27 21:18:28 1996
@@ -88,8 +88,9 @@
major(sb->st_rdev), minor(sb->st_rdev));
return 1;
case S_IFBLK:
- (void) printf("block special (%d/%d)",
+ (void) printf("block special (%d/%d) ",
major(sb->st_rdev), minor(sb->st_rdev));
+ return 0;
return 1;
/* TODO add code to handle V7 MUX and Blit MUX files */
#ifdef S_IFIFO
----------------------------
Then I created a new magic file (after looking around in the linux
include files for offset and magic):

----------------fs_magic file
0x0438 short 0xef53 ext2-fs
----------------
and now this:

felix root ~# fdisk -l 2>/dev/null | awk '/^\/dev/ { print $1 }' |
> xargs /usr/src/system/file-3.15/file -m fs_magic
/dev/sda1: block special (8/1) data
/dev/sdb1: block special (8/17) ext2-fs
/dev/sdb2: block special (8/18) data
/dev/sdb3: block special (8/19) data
/dev/sdb5: block special (8/21) ext2-fs
/dev/sdb6: block special (8/22) ext2-fs
/dev/sdb7: block special (8/23) ext2-fs
/dev/sdb8: block special (8/24) ext2-fs
should be easy to add other filesystems too. Now we have the next
problem: which of them is the root-filesystem? Mount them all and look for
a characteristic file (maybe /proc directory?) ?

Gerd

> Bjorn
>
>
>

Gerd Knorr <kraxel@cs.tu-berlin.de> | http://www.cs.tu-berlin.de/~kraxel/


\
 
 \ /
  Last update: 2005-03-22 13:36    [W:0.082 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site