[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
/*
2006-03-28 04:52:58 +04:00
* vol_id - read filesystem label and uuid
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
*
2006-03-28 04:52:58 +04:00
* Copyright ( C ) 2005 - 2006 Kay Sievers < kay . sievers @ vrfy . org >
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
*
* This program is free software ; you can redistribute it and / or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License .
*
* This program is distributed in the hope that it will be useful , but
* WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* General Public License for more details .
*
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*
*/
2005-03-11 04:31:58 +03:00
# ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
# endif
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
2004-09-19 10:22:27 +04:00
# include <string.h>
2004-05-12 11:52:52 +04:00
# include <ctype.h>
2006-08-20 20:24:34 +04:00
# include <errno.h>
# include <pwd.h>
2006-01-13 15:18:41 +03:00
# include <grp.h>
2004-09-05 20:05:36 +04:00
# include <sys/ioctl.h>
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
2006-01-09 23:18:00 +03:00
# include "../../udev.h"
2006-03-27 20:05:17 +04:00
# include "lib/libvolume_id.h"
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
2004-09-19 10:22:27 +04:00
# define BLKGETSIZE64 _IOR(0x12,114,size_t)
2005-03-06 12:15:51 +03:00
# ifdef USE_LOG
2005-06-05 07:17:21 +04:00
void log_message ( int priority , const char * format , . . . )
2004-05-12 11:52:52 +04:00
{
va_list args ;
2005-06-05 07:17:21 +04:00
static int udev_log = - 1 ;
if ( udev_log = = - 1 ) {
const char * value ;
value = getenv ( " UDEV_LOG " ) ;
if ( value )
udev_log = log_priority ( value ) ;
else
udev_log = LOG_ERR ;
}
if ( priority > udev_log )
return ;
2004-05-12 11:52:52 +04:00
va_start ( args , format ) ;
2005-06-05 07:17:21 +04:00
vsyslog ( priority , format , args ) ;
2004-05-12 11:52:52 +04:00
va_end ( args ) ;
}
# endif
2006-03-27 19:59:22 +04:00
static void vid_log ( int priority , const char * file , int line , const char * format , . . . )
{
# ifdef USE_LOG
2006-04-28 19:52:09 +04:00
char log_str [ 1024 ] ;
2006-03-27 19:59:22 +04:00
va_list args ;
va_start ( args , format ) ;
2006-04-28 19:52:09 +04:00
vsnprintf ( log_str , sizeof ( log_str ) , format , args ) ;
log_str [ sizeof ( log_str ) - 1 ] = ' \0 ' ;
log_message ( priority , " %s:%i %s " , file , line , log_str ) ;
2006-03-27 19:59:22 +04:00
va_end ( args ) ;
# endif
return ;
}
2005-08-01 03:33:36 +04:00
static void set_str ( char * to , const char * from , size_t count )
2005-06-26 03:54:47 +04:00
{
2005-08-01 03:33:36 +04:00
size_t i , j , len ;
2005-06-26 03:54:47 +04:00
2005-08-01 03:33:36 +04:00
/* strip trailing whitespace */
2005-06-26 03:54:47 +04:00
len = strnlen ( from , count ) ;
2005-08-22 13:37:12 +04:00
while ( len & & isspace ( from [ len - 1 ] ) )
2005-06-26 03:54:47 +04:00
len - - ;
2005-08-01 03:33:36 +04:00
/* strip leading whitespace */
2005-06-26 03:54:47 +04:00
i = 0 ;
while ( isspace ( from [ i ] ) & & ( i < len ) )
i + + ;
j = 0 ;
while ( i < len ) {
2005-08-01 03:33:36 +04:00
/* substitute multiple whitespace */
if ( isspace ( from [ i ] ) ) {
while ( isspace ( from [ i ] ) )
i + + ;
2005-06-26 03:54:47 +04:00
to [ j + + ] = ' _ ' ;
}
2005-08-01 03:33:36 +04:00
/* skip chars */
if ( from [ i ] = = ' / ' ) {
i + + ;
continue ;
}
to [ j + + ] = from [ i + + ] ;
2005-06-26 03:54:47 +04:00
}
to [ j ] = ' \0 ' ;
}
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
2004-05-12 11:52:52 +04:00
int main ( int argc , char * argv [ ] )
{
2006-07-13 18:59:01 +04:00
const char help [ ] = " Usage: vol_id [options] <device> \n "
" --export export key/value pairs \n "
" -t filesystem type \n "
" -l filesystem label \n "
" -u filesystem uuid \n "
2007-01-22 00:49:45 +03:00
" -L raw label \n "
2006-07-13 18:59:01 +04:00
" --skip-raid don't probe for raid \n "
" --probe-all find possibly conflicting signatures \n "
" --help \n "
2004-05-12 11:52:52 +04:00
" \n " ;
2005-06-26 03:54:47 +04:00
enum print_type {
PRINT_EXPORT ,
PRINT_TYPE ,
PRINT_LABEL ,
PRINT_UUID ,
2007-01-22 00:49:45 +03:00
PRINT_RAW_LABEL ,
2005-06-26 03:54:47 +04:00
} print = PRINT_EXPORT ;
2004-05-12 11:52:52 +04:00
struct volume_id * vid = NULL ;
static char name [ VOLUME_ID_LABEL_SIZE ] ;
2005-06-26 03:54:47 +04:00
int i ;
2005-08-01 03:33:36 +04:00
uint64_t size ;
2006-07-13 18:59:01 +04:00
int skip_raid = 0 ;
int probe_all = 0 ;
2005-06-26 03:54:47 +04:00
const char * node = NULL ;
2006-08-20 20:24:34 +04:00
struct passwd * pw ;
2006-07-13 18:59:01 +04:00
int retval ;
2005-06-26 03:54:47 +04:00
int rc = 0 ;
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
2005-06-26 20:55:24 +04:00
logging_init ( " vol_id " ) ;
2004-10-19 09:57:41 +04:00
2006-03-27 19:59:22 +04:00
/* hook in our debug into libvolume_id */
2006-03-28 04:52:58 +04:00
volume_id_log_fn = vid_log ;
2006-03-27 19:59:22 +04:00
2005-06-26 03:54:47 +04:00
for ( i = 1 ; i < argc ; i + + ) {
char * arg = argv [ i ] ;
if ( strcmp ( arg , " --export " ) = = 0 ) {
print = PRINT_EXPORT ;
} else if ( strcmp ( arg , " -t " ) = = 0 ) {
print = PRINT_TYPE ;
} else if ( strcmp ( arg , " -l " ) = = 0 ) {
print = PRINT_LABEL ;
} else if ( strcmp ( arg , " -u " ) = = 0 ) {
print = PRINT_UUID ;
2007-01-22 00:49:45 +03:00
} else if ( strcmp ( arg , " -L " ) = = 0 ) {
print = PRINT_RAW_LABEL ;
2006-07-13 18:59:01 +04:00
} else if ( strcmp ( arg , " --skip-raid " ) = = 0 ) {
skip_raid = 1 ;
} else if ( strcmp ( arg , " --probe-all " ) = = 0 ) {
probe_all = 1 ;
} else if ( strcmp ( arg , " --help " ) = = 0 | | strcmp ( arg , " -h " ) = = 0 ) {
printf ( help ) ;
goto exit ;
2005-06-26 03:54:47 +04:00
} else
node = arg ;
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
}
2005-06-26 03:54:47 +04:00
if ( ! node ) {
err ( " no node specified " ) ;
fprintf ( stderr , help ) ;
rc = 1 ;
goto exit ;
2004-05-12 11:52:52 +04:00
}
2005-06-26 03:54:47 +04:00
vid = volume_id_open_node ( node ) ;
2005-02-10 11:35:52 +03:00
if ( vid = = NULL ) {
2005-07-13 13:23:21 +04:00
fprintf ( stderr , " %s: error open volume \n " , node ) ;
2005-06-26 03:54:47 +04:00
rc = 2 ;
2004-05-12 11:52:52 +04:00
goto exit ;
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
}
2005-02-10 11:35:52 +03:00
if ( ioctl ( vid - > fd , BLKGETSIZE64 , & size ) ! = 0 )
size = 0 ;
2007-03-18 14:55:21 +03:00
dbg ( " BLKGETSIZE64=%llu " , ( unsigned long long ) size ) ;
2004-09-05 20:05:36 +04:00
2006-08-20 20:24:34 +04:00
/* try to drop all privileges before reading disk content */
pw = getpwnam ( " nobody " ) ;
if ( pw ! = NULL & & pw - > pw_uid > 0 & & pw - > pw_gid > 0 ) {
2007-02-25 01:43:04 +03:00
dbg ( " dropping privileges to %u:%u " ,
( unsigned int ) pw - > pw_uid , ( unsigned int ) pw - > pw_gid ) ;
2006-01-13 15:18:41 +03:00
if ( setgroups ( 0 , NULL ) ! = 0 | |
2006-08-20 20:24:34 +04:00
setgid ( pw - > pw_gid ) ! = 0 | |
setuid ( pw - > pw_uid ) ! = 0 ) {
fprintf ( stderr , " error dropping privileges: %s \n " , strerror ( errno ) ) ;
2006-01-13 15:18:41 +03:00
rc = 3 ;
goto exit ;
}
}
2006-07-13 18:59:01 +04:00
if ( probe_all ) {
if ( volume_id_probe_linux_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
if ( volume_id_probe_intel_software_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
if ( volume_id_probe_lsi_mega_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
if ( volume_id_probe_via_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
if ( volume_id_probe_silicon_medley_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
if ( volume_id_probe_nvidia_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
if ( volume_id_probe_promise_fasttrack_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
if ( volume_id_probe_highpoint_45x_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
if ( volume_id_probe_adaptec_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
if ( volume_id_probe_jmicron_raid ( vid , 0 , size ) = = 0 )
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_vfat ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_linux_swap ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_luks ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_xfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_ext ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_reiserfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_jfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_udf ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_iso9660 ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_hfs_hfsplus ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_ufs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_ntfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_cramfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_romfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_hpfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_sysv ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_minix ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_ocfs1 ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_ocfs2 ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_vxfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_squashfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_netware ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_gfs ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
2006-07-25 16:59:50 +04:00
if ( volume_id_probe_gfs2 ( vid , 0 , 0 ) = = 0 )
2006-07-13 18:59:01 +04:00
printf ( " %s \n " , vid - > type ) ;
goto exit ;
}
2004-09-05 20:05:36 +04:00
2006-07-13 18:59:01 +04:00
if ( skip_raid )
retval = volume_id_probe_filesystem ( vid , 0 , size ) ;
else
retval = volume_id_probe_all ( vid , 0 , size ) ;
if ( retval ! = 0 ) {
2005-07-13 13:23:21 +04:00
fprintf ( stderr , " %s: unknown volume type \n " , node ) ;
2006-07-13 18:59:01 +04:00
rc = 4 ;
goto exit ;
}
2004-05-12 11:52:52 +04:00
2005-06-26 03:54:47 +04:00
set_str ( name , vid - > label , sizeof ( vid - > label ) ) ;
2005-08-29 01:16:56 +04:00
replace_untrusted_chars ( name ) ;
2004-05-12 11:52:52 +04:00
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
switch ( print ) {
2005-06-26 03:54:47 +04:00
case PRINT_EXPORT :
printf ( " ID_FS_USAGE=%s \n " , vid - > usage ) ;
printf ( " ID_FS_TYPE=%s \n " , vid - > type ) ;
printf ( " ID_FS_VERSION=%s \n " , vid - > type_version ) ;
printf ( " ID_FS_UUID=%s \n " , vid - > uuid ) ;
printf ( " ID_FS_LABEL=%s \n " , vid - > label ) ;
printf ( " ID_FS_LABEL_SAFE=%s \n " , name ) ;
break ;
case PRINT_TYPE :
2004-09-05 20:05:36 +04:00
printf ( " %s \n " , vid - > type ) ;
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
break ;
2005-06-26 03:54:47 +04:00
case PRINT_LABEL :
2006-08-20 20:23:48 +04:00
if ( name [ 0 ] = = ' \0 ' | | vid - > usage_id = = VOLUME_ID_RAID ) {
2005-06-26 03:54:47 +04:00
rc = 3 ;
2004-05-12 11:52:52 +04:00
goto exit ;
}
printf ( " %s \n " , name ) ;
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
break ;
2005-06-26 03:54:47 +04:00
case PRINT_UUID :
2006-08-20 20:23:48 +04:00
if ( vid - > uuid [ 0 ] = = ' \0 ' | | vid - > usage_id = = VOLUME_ID_RAID ) {
2005-06-26 03:54:47 +04:00
rc = 4 ;
2004-05-12 11:52:52 +04:00
goto exit ;
}
2004-09-05 20:05:36 +04:00
printf ( " %s \n " , vid - > uuid ) ;
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
break ;
2007-01-22 00:49:45 +03:00
case PRINT_RAW_LABEL :
if ( vid - > label [ 0 ] = = ' \0 ' | | vid - > usage_id = = VOLUME_ID_RAID ) {
rc = 3 ;
goto exit ;
}
printf ( " %s \n " , vid - > label ) ;
break ;
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
}
2004-05-12 11:52:52 +04:00
exit :
if ( vid ! = NULL )
volume_id_close ( vid ) ;
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
2004-10-19 09:57:41 +04:00
logging_close ( ) ;
2005-06-26 03:54:47 +04:00
return rc ;
[PATCH] udev callout for reading filesystem labels
here is a small udev toy, which enables udev to name partitions by
its filesystem label or uuid's.
The following udev rule:
KERNEL="sd*", PROGRAM="/sbin/udev_volume_id -M%M -m%m -u", SYMLINK="%c"
creates a symlink with the uuid read from the filesystem. If no label or
uuid is found the program exits with nonzero and the rule will fail.
ext2, ext3, reiserfs, xfs, jfs, vfat, msdos volume labels are supported,
ntfs and swap partitions can be recognized.
It's possible to compile with klibc and the static binary takes 13kb.
2004-05-01 10:26:33 +04:00
}