* Hacking linux-utils for swap label
@ 2006-04-13 9:00 Loiseleur Michel
2006-04-13 12:16 ` Erik Mouw
2006-04-13 12:36 ` Evgeniy Dushistov
0 siblings, 2 replies; 9+ messages in thread
From: Loiseleur Michel @ 2006-04-13 9:00 UTC (permalink / raw)
To: linux-fsdevel
Hello everyone,
It's my first time in hacking something so deep in linux, so please
don't be too hard on me. It concerns the code packaged in "linux-utils",
I hope I have found the correct mailing list.
Here is the problem :
I need a way in shell script to get back the device name from the
label name, in order to restore (ie: format) it correctly in a recovery
solution (mondorescue).
For instance, a call to "e2label" do the job for the ext2/3 kind of
partition.
But for swap partition, there is _no_ way to get it back. The name
didn't appear in /proc/swaps or /proc/partitions.
Here is my current hacking:
I have developped myself a small "addon" to swapon/swapoff program,
named _swaplabel_, which display the list of device, uuid and name of
all the partitions. It was really easy, this code is old but so damn cool !
Here is the question :
1) Is this possible to enhance linux-utils in order to do the job ?
2) What's the better way to correct this :
2.1) a new program as my "swaplabel" ?
2.2) a new option to swapon ? (there is already a "-l" in it,
but it does not display the label)
2.3) a patch to the "-l" option ?
2.4) a patch to add a colum "label" in /proc/partitions ?
2.5) an other way I didn't think of ?
thanks for your help,
kind regards,
--
Michel Loiseleur
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hacking linux-utils for swap label
2006-04-13 9:00 Hacking linux-utils for swap label Loiseleur Michel
@ 2006-04-13 12:16 ` Erik Mouw
2006-04-13 12:34 ` Loiseleur Michel
2006-04-13 12:36 ` Evgeniy Dushistov
1 sibling, 1 reply; 9+ messages in thread
From: Erik Mouw @ 2006-04-13 12:16 UTC (permalink / raw)
To: Loiseleur Michel; +Cc: linux-fsdevel
On Thu, Apr 13, 2006 at 11:00:45AM +0200, Loiseleur Michel wrote:
> Here is the problem :
> I need a way in shell script to get back the device name from the
> label name, in order to restore (ie: format) it correctly in a recovery
> solution (mondorescue).
> For instance, a call to "e2label" do the job for the ext2/3 kind of
> partition.
> But for swap partition, there is _no_ way to get it back. The name
> didn't appear in /proc/swaps or /proc/partitions.
That's because filesystem labels is a userland issue and not at all
kernel related. It's also how mount label works: the userland program
"mount" figures out which device contains the requested label and
passes the correct device to the mount() syscall.
> Here is my current hacking:
> I have developped myself a small "addon" to swapon/swapoff program,
> named _swaplabel_, which display the list of device, uuid and name of
> all the partitions. It was really easy, this code is old but so damn cool !
>
> Here is the question :
> 1) Is this possible to enhance linux-utils in order to do the job ?
> 2) What's the better way to correct this :
> 2.1) a new program as my "swaplabel" ?
Yes, but rather name it something like dumpswap, just like dumpe2fs,
etc.
> 2.2) a new option to swapon ? (there is already a "-l" in it,
> but it does not display the label)
No, mount also doesn't display labels.
> 2.3) a patch to the "-l" option ?
> 2.4) a patch to add a colum "label" in /proc/partitions ?
No, cause labels are a userland issue.
Erik
--
+-- Erik Mouw -- www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hacking linux-utils for swap label
2006-04-13 12:16 ` Erik Mouw
@ 2006-04-13 12:34 ` Loiseleur Michel
0 siblings, 0 replies; 9+ messages in thread
From: Loiseleur Michel @ 2006-04-13 12:34 UTC (permalink / raw)
To: linux-fsdevel
Erik Mouw a écrit :
>On Thu, Apr 13, 2006 at 11:00:45AM +0200, Loiseleur Michel wrote:
>
>
>>Here is the problem :
>> I need a way in shell script to get back the device name from the
>>label name, in order to restore (ie: format) it correctly in a recovery
>>solution (mondorescue).
>> For instance, a call to "e2label" do the job for the ext2/3 kind of
>>partition.
>> But for swap partition, there is _no_ way to get it back. The name
>>didn't appear in /proc/swaps or /proc/partitions.
>>
>>
>
>That's because filesystem labels is a userland issue and not at all
>kernel related. It's also how mount label works: the userland program
>"mount" figures out which device contains the requested label and
>passes the correct device to the mount() syscall.
>
>
>
>>Here is my current hacking:
>> I have developped myself a small "addon" to swapon/swapoff program,
>>named _swaplabel_, which display the list of device, uuid and name of
>>all the partitions. It was really easy, this code is old but so damn cool !
>>
>>Here is the question :
>> 1) Is this possible to enhance linux-utils in order to do the job ?
>> 2) What's the better way to correct this :
>> 2.1) a new program as my "swaplabel" ?
>>
>>
>
>Yes, but rather name it something like dumpswap, just like dumpe2fs,
>etc.
>
>
This is not exactly what I need. I don't know how to dress the full map
of a swap file/partition, and I don't need it. I just need to retrieve
the link between 'device' and 'label' put in /etc/fstab. After reading
the code in linux-utils package (mount/swapon.c &
mount/get_label_uuid.c), I figured out how to implement it in C. But I
need it in shell script >_<.
The program I want to add is nearer of e2label program (ext2/3
equivalent). That's why I suggested the name "swaplabel", which would be
functionally equivalent to e2label.
>
>
>> 2.2) a new option to swapon ? (there is already a "-l" in it,
>>but it does not display the label)
>>
>>
>
>No, mount also doesn't display labels.
>
>
ok
>
>
>> 2.3) a patch to the "-l" option ?
>> 2.4) a patch to add a colum "label" in /proc/partitions ?
>>
>>
>
>No, cause labels are a userland issue.
>
>
Yes, you're right. I wanted to join linux-utils developers, and it's the
mailing list which seems the good one for me.
Thanks for your advice, erik.
--
Michel Loiseleur
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hacking linux-utils for swap label
2006-04-13 9:00 Hacking linux-utils for swap label Loiseleur Michel
2006-04-13 12:16 ` Erik Mouw
@ 2006-04-13 12:36 ` Evgeniy Dushistov
2006-04-13 13:12 ` Loiseleur Michel
2006-04-13 16:37 ` Greg KH
1 sibling, 2 replies; 9+ messages in thread
From: Evgeniy Dushistov @ 2006-04-13 12:36 UTC (permalink / raw)
To: linux-fsdevel
On Thu, Apr 13, 2006 at 11:00:45AM +0200, Loiseleur Michel wrote:
> Hello everyone,
>
> It's my first time in hacking something so deep in linux, so please
> don't be too hard on me. It concerns the code packaged in "linux-utils",
> I hope I have found the correct mailing list.
>
>
> Here is the problem :
> I need a way in shell script to get back the device name from the
> label name, in order to restore (ie: format) it correctly in a recovery
> solution (mondorescue).
> For instance, a call to "e2label" do the job for the ext2/3 kind of
> partition.
> But for swap partition, there is _no_ way to get it back. The name
> didn't appear in /proc/swaps or /proc/partitions.
>
> Here is my current hacking:
> I have developped myself a small "addon" to swapon/swapoff program,
> named _swaplabel_, which display the list of device, uuid and name of
> all the partitions. It was really easy, this code is old but so damn cool !
>
> Here is the question :
> 1) Is this possible to enhance linux-utils in order to do the job ?
> 2) What's the better way to correct this :
> 2.1) a new program as my "swaplabel" ?
> 2.2) a new option to swapon ? (there is already a "-l" in it,
> but it does not display the label)
> 2.3) a patch to the "-l" option ?
> 2.4) a patch to add a colum "label" in /proc/partitions ?
> 2.5) an other way I didn't think of ?
>
> thanks for your help,
> kind regards,
>
May be I don't understand something, but there is
http://e2fsprogs.sourceforge.net/
and it contains blkid utility and which used for handle LABEL= in
/etc/fstab,
in spite of name it handles many types of file systems and swap
partitions also.
--
/Evgeniy
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hacking linux-utils for swap label
2006-04-13 12:36 ` Evgeniy Dushistov
@ 2006-04-13 13:12 ` Loiseleur Michel
2006-04-13 16:37 ` Greg KH
1 sibling, 0 replies; 9+ messages in thread
From: Loiseleur Michel @ 2006-04-13 13:12 UTC (permalink / raw)
To: Evgeniy Dushistov, linux-fsdevel
Evgeniy Dushistov a écrit :
>On Thu, Apr 13, 2006 at 11:00:45AM +0200, Loiseleur Michel wrote:
>
>
>>Hello everyone,
>>
>> It's my first time in hacking something so deep in linux, so please
>>don't be too hard on me. It concerns the code packaged in "linux-utils",
>>I hope I have found the correct mailing list.
>>
>>
>>Here is the problem :
>> I need a way in shell script to get back the device name from the
>>label name, in order to restore (ie: format) it correctly in a recovery
>>solution (mondorescue).
>> For instance, a call to "e2label" do the job for the ext2/3 kind of
>>partition.
>> But for swap partition, there is _no_ way to get it back. The name
>>didn't appear in /proc/swaps or /proc/partitions.
>>
>>Here is my current hacking:
>> I have developped myself a small "addon" to swapon/swapoff program,
>>named _swaplabel_, which display the list of device, uuid and name of
>>all the partitions. It was really easy, this code is old but so damn cool !
>>
>>Here is the question :
>> 1) Is this possible to enhance linux-utils in order to do the job ?
>> 2) What's the better way to correct this :
>> 2.1) a new program as my "swaplabel" ?
>> 2.2) a new option to swapon ? (there is already a "-l" in it,
>>but it does not display the label)
>> 2.3) a patch to the "-l" option ?
>> 2.4) a patch to add a colum "label" in /proc/partitions ?
>> 2.5) an other way I didn't think of ?
>>
>>thanks for your help,
>>kind regards,
>>
>>
>>
>May be I don't understand something, but there is
>http://e2fsprogs.sourceforge.net/
>and it contains blkid utility and which used for handle LABEL= in
>/etc/fstab,
>in spite of name it handles many types of file systems and swap
>partitions also.
>
>
Thanks a lot to you. It was ... hum ... not obvious. I can do the job
with it. No needs to patch anything ! I can parse in shell script the
output of "blkid".
kind regards,
--
Michel
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hacking linux-utils for swap label
2006-04-13 12:36 ` Evgeniy Dushistov
2006-04-13 13:12 ` Loiseleur Michel
@ 2006-04-13 16:37 ` Greg KH
2006-04-13 16:52 ` Theodore Ts'o
1 sibling, 1 reply; 9+ messages in thread
From: Greg KH @ 2006-04-13 16:37 UTC (permalink / raw)
To: linux-fsdevel
On Thu, Apr 13, 2006 at 04:36:19PM +0400, Evgeniy Dushistov wrote:
> May be I don't understand something, but there is
> http://e2fsprogs.sourceforge.net/
> and it contains blkid utility and which used for handle LABEL= in
> /etc/fstab,
> in spite of name it handles many types of file systems and swap
> partitions also.
vol_id in the udev package is much better than blkid, as it handles more
file system types, and is easier to intregrate into other programs and
scripts (it's also availble as a library.) I would recommend it
instead.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hacking linux-utils for swap label
2006-04-13 16:37 ` Greg KH
@ 2006-04-13 16:52 ` Theodore Ts'o
2006-04-13 17:10 ` Greg KH
0 siblings, 1 reply; 9+ messages in thread
From: Theodore Ts'o @ 2006-04-13 16:52 UTC (permalink / raw)
To: Greg KH; +Cc: linux-fsdevel
On Thu, Apr 13, 2006 at 09:37:24AM -0700, Greg KH wrote:
> vol_id in the udev package is much better than blkid, as it handles more
> file system types, and is easier to intregrate into other programs and
> scripts (it's also availble as a library.) I would recommend it
> instead.
For the record, blkid is also available as a library, and it is what
is used by mount and fsck to support. Blkid also has the advantage
that it doesn't require a modern 2.6 kernel to function (since it
isn't dependent on udev) in order to find the device where a
particular filesystem with a particular label or UUID. Blkid is
available on pretty much all distributions since it's been part of
e2fsprogs since 2002 or so; udev is used available on all reasonably
modern distro's using a 2.6 kernel.
Finally, the number of filesystem types handled by the two really
aren't all that different; certainly all of the major filesystem types
are covered by both libraries/programs.
Regards,
- Ted
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hacking linux-utils for swap label
2006-04-13 16:52 ` Theodore Ts'o
@ 2006-04-13 17:10 ` Greg KH
2006-04-13 18:19 ` Theodore Ts'o
0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2006-04-13 17:10 UTC (permalink / raw)
To: Theodore Ts'o; +Cc: linux-fsdevel
On Thu, Apr 13, 2006 at 12:52:26PM -0400, Theodore Ts'o wrote:
> Blkid also has the advantage that it doesn't require a modern 2.6
> kernel to function (since it isn't dependent on udev) in order to find
> the device where a particular filesystem with a particular label or
> UUID.
I don't see that requirement anywhere in the vol_id code. It's a
stand-alone binary that should work with just about any kernel version,
as it just talks to the block device directly. No udev requirement at
all (it just happens to live in the udev source tree for now, I think
that's changing as HAL and some other utilities are starting to rely on
it.)
Anyway, I don't have any objection to blkid, just trying to point out
another solution, instead of having the original poster try to reinvent
the wheel again :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Hacking linux-utils for swap label
2006-04-13 17:10 ` Greg KH
@ 2006-04-13 18:19 ` Theodore Ts'o
0 siblings, 0 replies; 9+ messages in thread
From: Theodore Ts'o @ 2006-04-13 18:19 UTC (permalink / raw)
To: Greg KH; +Cc: linux-fsdevel
On Thu, Apr 13, 2006 at 10:10:42AM -0700, Greg KH wrote:
> I don't see that requirement anywhere in the vol_id code. It's a
> stand-alone binary that should work with just about any kernel version,
> as it just talks to the block device directly. No udev requirement at
> all (it just happens to live in the udev source tree for now, I think
> that's changing as HAL and some other utilities are starting to rely on
> it.)
The blkid library/program does many things, beyond just simply
identifying the filesystem type, label, and uuid given a particular
device. In particular, the blkid library uses a cache (so you don't
have to scan all of the attached block devices, which in the case of a
system with a truly vast number of san attached storage devices, could
take very long time), so that an application can find a block device
given a particular label or uuid as a search parameter.
That was what was originally requested, and that is something which
vol_id can not do unassisted (but which blkid can do, either from the
command-line or from the C library interface).
Udev can provide this functionality, if you are running on a modern
distribution that uses udev, and it does so by scanning all block
devices at hotplug/coldplug time. I'm not entirely convinced that is
the right approach if there are several hundred thousand potential
devices available via a SAN fabric, or via iSCSI --- and to be fair,
blkid probably won't be enough in that environment, either. But it
provides a nice abstraction interface so that in the future, blkid
could optionally call out to some directory service to find the
location of the iSCSI device. In contrast, the udev solution to the
find-the-device-given-a-uuid assumes that a symlink has been created,
which makes it more difficult to trap the request to look for a
particular UUID/label.
> Anyway, I don't have any objection to blkid, just trying to point out
> another solution, instead of having the original poster try to reinvent
> the wheel again :)
And I don't have an objection to udev, although I'm not convineced
it's proposed solution for finding block devices given a UUID or label
is the best one....
- Ted
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-04-13 18:20 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-13 9:00 Hacking linux-utils for swap label Loiseleur Michel
2006-04-13 12:16 ` Erik Mouw
2006-04-13 12:34 ` Loiseleur Michel
2006-04-13 12:36 ` Evgeniy Dushistov
2006-04-13 13:12 ` Loiseleur Michel
2006-04-13 16:37 ` Greg KH
2006-04-13 16:52 ` Theodore Ts'o
2006-04-13 17:10 ` Greg KH
2006-04-13 18:19 ` Theodore Ts'o
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.