vol_id.c revision 915fde17387f7245164fbda21a0f5bbc185f7dc2
/*
* vol_id - read filesystem label and uuid
*
* Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
*
* 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 02139, USA.
*
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <pwd.h>
#include <grp.h>
#include "../../udev.h"
#include "lib/libvolume_id.h"
#ifdef USE_LOG
{
static int udev_log = -1;
if (udev_log == -1) {
const char *value;
if (value)
else
}
return;
}
#endif
{
#ifdef USE_LOG
char log_str[1024];
#endif
return;
}
{
/* strip trailing whitespace */
len--;
/* strip leading whitespace */
i = 0;
i++;
j = 0;
while (i < len) {
/* substitute multiple whitespace */
i++;
to[j++] = '_';
}
/* skip chars */
if (from[i] == '/') {
i++;
continue;
}
}
to[j] = '\0';
}
{
const char help[] = "Usage: vol_id [options] <device>\n"
" -t filesystem type\n"
" -l filesystem label\n"
" -u filesystem uuid\n"
" -L raw label\n"
" --skip-raid don't probe for raid\n"
" --probe-all find possibly conflicting signatures\n"
" --help\n"
"\n";
enum print_type {
} print = PRINT_EXPORT;
static char name[VOLUME_ID_LABEL_SIZE];
int i;
int skip_raid = 0;
int probe_all = 0;
int retval;
int rc = 0;
logging_init("vol_id");
/* hook in our debug into libvolume_id */
for (i = 1 ; i < argc; i++) {
print = PRINT_TYPE;
print = PRINT_LABEL;
print = PRINT_UUID;
skip_raid = 1;
probe_all = 1;
goto exit;
} else
}
if (!node) {
err("no node specified");
rc = 1;
goto exit;
}
rc = 2;
goto exit;
}
size = 0;
/* try to drop all privileges before reading disk content */
dbg("dropping privileges to %u:%u",
rc = 3;
goto exit;
}
}
if (probe_all) {
if (volume_id_probe_vfat(vid, 0, 0) == 0)
if (volume_id_probe_linux_swap(vid, 0, 0) == 0)
if (volume_id_probe_luks(vid, 0, 0) == 0)
if (volume_id_probe_xfs(vid, 0, 0) == 0)
if (volume_id_probe_ext(vid, 0, 0) == 0)
if (volume_id_probe_reiserfs(vid, 0, 0) == 0)
if (volume_id_probe_jfs(vid, 0, 0) == 0)
if (volume_id_probe_udf(vid, 0, 0) == 0)
if (volume_id_probe_iso9660(vid, 0, 0) == 0)
if (volume_id_probe_hfs_hfsplus(vid, 0, 0) == 0)
if (volume_id_probe_ufs(vid, 0, 0) == 0)
if (volume_id_probe_ntfs(vid, 0, 0) == 0)
if (volume_id_probe_cramfs(vid, 0, 0) == 0)
if (volume_id_probe_romfs(vid, 0, 0) == 0)
if (volume_id_probe_hpfs(vid, 0, 0) == 0)
if (volume_id_probe_sysv(vid, 0, 0) == 0)
if (volume_id_probe_minix(vid, 0, 0) == 0)
if (volume_id_probe_ocfs1(vid, 0, 0) == 0)
if (volume_id_probe_ocfs2(vid, 0, 0) == 0)
if (volume_id_probe_vxfs(vid, 0, 0) == 0)
if (volume_id_probe_squashfs(vid, 0, 0) == 0)
if (volume_id_probe_netware(vid, 0, 0) == 0)
if (volume_id_probe_gfs(vid, 0, 0) == 0)
if (volume_id_probe_gfs2(vid, 0, 0) == 0)
goto exit;
}
if (skip_raid)
else
if (retval != 0) {
rc = 4;
goto exit;
}
switch (print) {
case PRINT_EXPORT:
break;
case PRINT_TYPE:
break;
case PRINT_LABEL:
rc = 3;
goto exit;
}
break;
case PRINT_UUID:
rc = 4;
goto exit;
}
break;
case PRINT_RAW_LABEL:
rc = 3;
goto exit;
}
break;
}
exit:
return rc;
}