summaryrefslogtreecommitdiff
path: root/extras/volume_id/volume_id.h
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-04-30 23:26:33 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 21:35:17 -0700
commit3611d5820c0fc0863d15c04884b05c9e04492f45 (patch)
tree594698488dc499c4ba88afa07087d7c03efa93de /extras/volume_id/volume_id.h
parente13fa59953d64e478025fd1200bb5fd0baf671b2 (diff)
[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.
Diffstat (limited to 'extras/volume_id/volume_id.h')
-rw-r--r--extras/volume_id/volume_id.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/extras/volume_id/volume_id.h b/extras/volume_id/volume_id.h
new file mode 100644
index 0000000000..a0d2acda22
--- /dev/null
+++ b/extras/volume_id/volume_id.h
@@ -0,0 +1,72 @@
+/*
+ * volume_id - reads partition label and uuid
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * 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 02139, USA.
+ *
+ */
+
+#ifndef _VOLUME_ID_H_
+#define _VOLUME_ID_H_
+
+#define VOLUME_ID_VERSION 001
+
+#define VOLUME_ID_LABEL_SIZE 16
+#define VOLUME_ID_UUID_SIZE 16
+#define VOLUME_ID_UUID_STRING_SIZE 37
+#define VOLUME_ID_PATH_MAX 255
+
+
+enum filesystem_type {
+ ALL,
+ EXT2,
+ EXT3,
+ REISER,
+ XFS,
+ JFS,
+ MSDOS,
+ VFAT,
+ NTFS,
+ SWAP
+};
+
+struct volume_id {
+ char label[VOLUME_ID_LABEL_SIZE];
+ char label_string[VOLUME_ID_LABEL_SIZE+1];
+ unsigned char uuid[VOLUME_ID_UUID_SIZE];
+ char uuid_string[VOLUME_ID_UUID_STRING_SIZE];
+ enum filesystem_type fs_type;
+ char *fs_name;
+ int fd;
+ char *buf;
+ int fd_close;
+};
+
+/* open volume by already open file descriptor */
+extern struct volume_id *volume_id_open_fd(int fd);
+
+/* open volume by device node */
+extern struct volume_id *volume_id_open_node(const char *path);
+
+/* open volume by major/minor */
+extern struct volume_id *volume_id_open_dev_t(dev_t devt);
+
+/* probe volume for filesystem type and try to read label/uuid */
+extern int volume_id_probe(struct volume_id *id, enum filesystem_type fs_type);
+
+/* free allocated device info */
+extern void volume_id_close(struct volume_id *id);
+
+#endif