From e4d4a557e53c3fbcf14bd1bb29686fd884905b53 Mon Sep 17 00:00:00 2001 From: "kay.sievers@vrfy.org" Date: Wed, 23 Feb 2005 02:58:31 +0100 Subject: [PATCH] [PATCH] udev_volume_id: volume_id v35 --- extras/volume_id/udev_volume_id.c | 2 +- extras/volume_id/volume_id/Makefile.inc | 92 +++++++-------- .../volume_id/volume_id/{cramfs => }/cramfs.c | 6 +- .../volume_id/volume_id/{cramfs => }/cramfs.h | 0 extras/volume_id/volume_id/{dasd => }/dasd.c | 6 +- extras/volume_id/volume_id/{dasd => }/dasd.h | 0 extras/volume_id/volume_id/{ext => }/ext.c | 6 +- extras/volume_id/volume_id/{ext => }/ext.h | 0 extras/volume_id/volume_id/{fat => }/fat.c | 6 +- extras/volume_id/volume_id/{fat => }/fat.h | 0 extras/volume_id/volume_id/{hfs => }/hfs.c | 6 +- extras/volume_id/volume_id/{hfs => }/hfs.h | 0 .../volume_id/{highpoint => }/highpoint.c | 6 +- .../volume_id/{highpoint => }/highpoint.h | 0 extras/volume_id/volume_id/{hpfs => }/hpfs.c | 6 +- extras/volume_id/volume_id/{hpfs => }/hpfs.h | 0 .../volume_id/{iso9660 => }/iso9660.c | 6 +- .../volume_id/{iso9660 => }/iso9660.h | 0 extras/volume_id/volume_id/{jfs => }/jfs.c | 6 +- extras/volume_id/volume_id/{jfs => }/jfs.h | 0 .../volume_id/{linux_raid => }/linux_raid.c | 6 +- .../volume_id/{linux_raid => }/linux_raid.h | 0 .../volume_id/{linux_swap => }/linux_swap.c | 6 +- .../volume_id/{linux_swap => }/linux_swap.h | 0 extras/volume_id/volume_id/luks.c | 106 ++++++++++++++++++ extras/volume_id/volume_id/luks.h | 26 +++++ extras/volume_id/volume_id/{lvm => }/lvm.c | 6 +- extras/volume_id/volume_id/{lvm => }/lvm.h | 0 extras/volume_id/volume_id/{mac => }/mac.c | 6 +- extras/volume_id/volume_id/{mac => }/mac.h | 0 .../volume_id/volume_id/{msdos => }/msdos.c | 6 +- .../volume_id/volume_id/{msdos => }/msdos.h | 0 extras/volume_id/volume_id/{ntfs => }/ntfs.c | 6 +- extras/volume_id/volume_id/{ntfs => }/ntfs.h | 0 .../volume_id/{reiserfs => }/reiserfs.c | 6 +- .../volume_id/{reiserfs => }/reiserfs.h | 0 .../volume_id/volume_id/{romfs => }/romfs.c | 6 +- .../volume_id/volume_id/{romfs => }/romfs.h | 0 extras/volume_id/volume_id/{sysv => }/sysv.c | 6 +- extras/volume_id/volume_id/{sysv => }/sysv.h | 0 extras/volume_id/volume_id/{udf => }/udf.c | 6 +- extras/volume_id/volume_id/{udf => }/udf.h | 0 extras/volume_id/volume_id/{ufs => }/ufs.c | 6 +- extras/volume_id/volume_id/{ufs => }/ufs.h | 0 extras/volume_id/volume_id/util.c | 2 + extras/volume_id/volume_id/volume_id.c | 47 ++++---- extras/volume_id/volume_id/volume_id.h | 3 +- extras/volume_id/volume_id/{xfs => }/xfs.c | 6 +- extras/volume_id/volume_id/{xfs => }/xfs.h | 0 49 files changed, 275 insertions(+), 129 deletions(-) rename extras/volume_id/volume_id/{cramfs => }/cramfs.c (96%) rename extras/volume_id/volume_id/{cramfs => }/cramfs.h (100%) rename extras/volume_id/volume_id/{dasd => }/dasd.c (99%) rename extras/volume_id/volume_id/{dasd => }/dasd.h (100%) rename extras/volume_id/volume_id/{ext => }/ext.c (97%) rename extras/volume_id/volume_id/{ext => }/ext.h (100%) rename extras/volume_id/volume_id/{fat => }/fat.c (99%) rename extras/volume_id/volume_id/{fat => }/fat.h (100%) rename extras/volume_id/volume_id/{hfs => }/hfs.c (99%) rename extras/volume_id/volume_id/{hfs => }/hfs.h (100%) rename extras/volume_id/volume_id/{highpoint => }/highpoint.c (96%) rename extras/volume_id/volume_id/{highpoint => }/highpoint.h (100%) rename extras/volume_id/volume_id/{hpfs => }/hpfs.c (96%) rename extras/volume_id/volume_id/{hpfs => }/hpfs.h (100%) rename extras/volume_id/volume_id/{iso9660 => }/iso9660.c (97%) rename extras/volume_id/volume_id/{iso9660 => }/iso9660.h (100%) rename extras/volume_id/volume_id/{jfs => }/jfs.c (96%) rename extras/volume_id/volume_id/{jfs => }/jfs.h (100%) rename extras/volume_id/volume_id/{linux_raid => }/linux_raid.c (97%) rename extras/volume_id/volume_id/{linux_raid => }/linux_raid.h (100%) rename extras/volume_id/volume_id/{linux_swap => }/linux_swap.c (96%) rename extras/volume_id/volume_id/{linux_swap => }/linux_swap.h (100%) create mode 100644 extras/volume_id/volume_id/luks.c create mode 100644 extras/volume_id/volume_id/luks.h rename extras/volume_id/volume_id/{lvm => }/lvm.c (97%) rename extras/volume_id/volume_id/{lvm => }/lvm.h (100%) rename extras/volume_id/volume_id/{mac => }/mac.c (98%) rename extras/volume_id/volume_id/{mac => }/mac.h (100%) rename extras/volume_id/volume_id/{msdos => }/msdos.c (98%) rename extras/volume_id/volume_id/{msdos => }/msdos.h (100%) rename extras/volume_id/volume_id/{ntfs => }/ntfs.c (98%) rename extras/volume_id/volume_id/{ntfs => }/ntfs.h (100%) rename extras/volume_id/volume_id/{reiserfs => }/reiserfs.c (97%) rename extras/volume_id/volume_id/{reiserfs => }/reiserfs.h (100%) rename extras/volume_id/volume_id/{romfs => }/romfs.c (96%) rename extras/volume_id/volume_id/{romfs => }/romfs.h (100%) rename extras/volume_id/volume_id/{sysv => }/sysv.c (97%) rename extras/volume_id/volume_id/{sysv => }/sysv.h (100%) rename extras/volume_id/volume_id/{udf => }/udf.c (98%) rename extras/volume_id/volume_id/{udf => }/udf.h (100%) rename extras/volume_id/volume_id/{ufs => }/ufs.c (98%) rename extras/volume_id/volume_id/{ufs => }/ufs.h (100%) rename extras/volume_id/volume_id/{xfs => }/xfs.c (96%) rename extras/volume_id/volume_id/{xfs => }/xfs.h (100%) diff --git a/extras/volume_id/udev_volume_id.c b/extras/volume_id/udev_volume_id.c index 843b70ba..c36b89f8 100644 --- a/extras/volume_id/udev_volume_id.c +++ b/extras/volume_id/udev_volume_id.c @@ -31,7 +31,7 @@ #include "../../udev_utils.h" #include "../../logging.h" #include "volume_id/volume_id.h" -#include "volume_id/dasd/dasd.h" +#include "volume_id/dasd.h" #define BLKGETSIZE64 _IOR(0x12,114,size_t) diff --git a/extras/volume_id/volume_id/Makefile.inc b/extras/volume_id/volume_id/Makefile.inc index d010f777..9cadec20 100644 --- a/extras/volume_id/volume_id/Makefile.inc +++ b/extras/volume_id/volume_id/Makefile.inc @@ -1,48 +1,50 @@ -VOLUME_ID_OBJS= \ - $(VOLUME_ID_BASE)/ext/ext.o \ - $(VOLUME_ID_BASE)/fat/fat.o \ - $(VOLUME_ID_BASE)/hfs/hfs.o \ - $(VOLUME_ID_BASE)/highpoint/highpoint.o \ - $(VOLUME_ID_BASE)/iso9660/iso9660.o \ - $(VOLUME_ID_BASE)/jfs/jfs.o \ - $(VOLUME_ID_BASE)/linux_raid/linux_raid.o \ - $(VOLUME_ID_BASE)/linux_swap/linux_swap.o \ - $(VOLUME_ID_BASE)/lvm/lvm.o \ - $(VOLUME_ID_BASE)/mac/mac.o \ - $(VOLUME_ID_BASE)/msdos/msdos.o \ - $(VOLUME_ID_BASE)/ntfs/ntfs.o \ - $(VOLUME_ID_BASE)/reiserfs/reiserfs.o \ - $(VOLUME_ID_BASE)/udf/udf.o \ - $(VOLUME_ID_BASE)/ufs/ufs.o \ - $(VOLUME_ID_BASE)/xfs/xfs.o \ - $(VOLUME_ID_BASE)/cramfs/cramfs.o \ - $(VOLUME_ID_BASE)/hpfs/hpfs.o \ - $(VOLUME_ID_BASE)/romfs/romfs.o \ - $(VOLUME_ID_BASE)/sysv/sysv.o \ - $(VOLUME_ID_BASE)/dasd/dasd.o \ - $(VOLUME_ID_BASE)/volume_id.o \ +VOLUME_ID_OBJS= \ + $(VOLUME_ID_BASE)/ext.o \ + $(VOLUME_ID_BASE)/fat.o \ + $(VOLUME_ID_BASE)/hfs.o \ + $(VOLUME_ID_BASE)/highpoint.o \ + $(VOLUME_ID_BASE)/iso9660.o \ + $(VOLUME_ID_BASE)/jfs.o \ + $(VOLUME_ID_BASE)/linux_raid.o \ + $(VOLUME_ID_BASE)/linux_swap.o \ + $(VOLUME_ID_BASE)/lvm.o \ + $(VOLUME_ID_BASE)/mac.o \ + $(VOLUME_ID_BASE)/msdos.o \ + $(VOLUME_ID_BASE)/ntfs.o \ + $(VOLUME_ID_BASE)/reiserfs.o \ + $(VOLUME_ID_BASE)/udf.o \ + $(VOLUME_ID_BASE)/ufs.o \ + $(VOLUME_ID_BASE)/xfs.o \ + $(VOLUME_ID_BASE)/cramfs.o \ + $(VOLUME_ID_BASE)/hpfs.o \ + $(VOLUME_ID_BASE)/romfs.o \ + $(VOLUME_ID_BASE)/sysv.o \ + $(VOLUME_ID_BASE)/dasd.o \ + $(VOLUME_ID_BASE)/luks.o \ + $(VOLUME_ID_BASE)/volume_id.o \ $(VOLUME_ID_BASE)/util.o -VOLUME_ID_HEADERS= \ - $(VOLUME_ID_BASE)/ext/ext.h \ - $(VOLUME_ID_BASE)/fat/fat.h \ - $(VOLUME_ID_BASE)/hfs/hfs.h \ - $(VOLUME_ID_BASE)/highpoint/highpoint.h \ - $(VOLUME_ID_BASE)/iso9660/iso9660.h \ - $(VOLUME_ID_BASE)/jfs/jfs.h \ - $(VOLUME_ID_BASE)/linux_raid/linux_raid.h \ - $(VOLUME_ID_BASE)/linux_swap/linux_swap.h \ - $(VOLUME_ID_BASE)/lvm/lvm.h \ - $(VOLUME_ID_BASE)/mac/mac.h \ - $(VOLUME_ID_BASE)/msdos/msdos.h \ - $(VOLUME_ID_BASE)/ntfs/ntfs.h \ - $(VOLUME_ID_BASE)/reiserfs/reiserfs.h \ - $(VOLUME_ID_BASE)/udf/udf.h \ - $(VOLUME_ID_BASE)/ufs/ufs.h \ - $(VOLUME_ID_BASE)/xfs/xfs.h \ - $(VOLUME_ID_BASE)/cramfs/cramfs.h \ - $(VOLUME_ID_BASE)/sysv/sysv.h \ - $(VOLUME_ID_BASE)/romfs/romfs.h \ - $(VOLUME_ID_BASE)/dasd/dasd.h \ - $(VOLUME_ID_BASE)/volume_id.h \ +VOLUME_ID_HEADERS= \ + $(VOLUME_ID_BASE)/ext.h \ + $(VOLUME_ID_BASE)/fat.h \ + $(VOLUME_ID_BASE)/hfs.h \ + $(VOLUME_ID_BASE)/highpoint.h \ + $(VOLUME_ID_BASE)/iso9660.h \ + $(VOLUME_ID_BASE)/jfs.h \ + $(VOLUME_ID_BASE)/linux_raid.h \ + $(VOLUME_ID_BASE)/linux_swap.h \ + $(VOLUME_ID_BASE)/lvm.h \ + $(VOLUME_ID_BASE)/mac.h \ + $(VOLUME_ID_BASE)/msdos.h \ + $(VOLUME_ID_BASE)/ntfs.h \ + $(VOLUME_ID_BASE)/reiserfs.h \ + $(VOLUME_ID_BASE)/udf.h \ + $(VOLUME_ID_BASE)/ufs.h \ + $(VOLUME_ID_BASE)/xfs.h \ + $(VOLUME_ID_BASE)/cramfs.h \ + $(VOLUME_ID_BASE)/sysv.h \ + $(VOLUME_ID_BASE)/romfs.h \ + $(VOLUME_ID_BASE)/dasd.h \ + $(VOLUME_ID_BASE)/luks.h \ + $(VOLUME_ID_BASE)/volume_id.h \ $(VOLUME_ID_BASE)/util.h diff --git a/extras/volume_id/volume_id/cramfs/cramfs.c b/extras/volume_id/volume_id/cramfs.c similarity index 96% rename from extras/volume_id/volume_id/cramfs/cramfs.c rename to extras/volume_id/volume_id/cramfs.c index a1d51f10..a8058646 100644 --- a/extras/volume_id/volume_id/cramfs/cramfs.c +++ b/extras/volume_id/volume_id/cramfs.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "cramfs.h" struct cramfs_super { diff --git a/extras/volume_id/volume_id/cramfs/cramfs.h b/extras/volume_id/volume_id/cramfs.h similarity index 100% rename from extras/volume_id/volume_id/cramfs/cramfs.h rename to extras/volume_id/volume_id/cramfs.h diff --git a/extras/volume_id/volume_id/dasd/dasd.c b/extras/volume_id/volume_id/dasd.c similarity index 99% rename from extras/volume_id/volume_id/dasd/dasd.c rename to extras/volume_id/volume_id/dasd.c index 2df6a09e..6f403cb9 100644 --- a/extras/volume_id/volume_id/dasd/dasd.c +++ b/extras/volume_id/volume_id/dasd.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "dasd.h" static unsigned char EBCtoASC[256] = diff --git a/extras/volume_id/volume_id/dasd/dasd.h b/extras/volume_id/volume_id/dasd.h similarity index 100% rename from extras/volume_id/volume_id/dasd/dasd.h rename to extras/volume_id/volume_id/dasd.h diff --git a/extras/volume_id/volume_id/ext/ext.c b/extras/volume_id/volume_id/ext.c similarity index 97% rename from extras/volume_id/volume_id/ext/ext.c rename to extras/volume_id/volume_id/ext.c index 0940e452..b7bdf05d 100644 --- a/extras/volume_id/volume_id/ext/ext.c +++ b/extras/volume_id/volume_id/ext.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../util.h" -#include "../logging.h" +#include "volume_id.h" +#include "util.h" +#include "logging.h" #include "ext.h" struct ext2_super_block { diff --git a/extras/volume_id/volume_id/ext/ext.h b/extras/volume_id/volume_id/ext.h similarity index 100% rename from extras/volume_id/volume_id/ext/ext.h rename to extras/volume_id/volume_id/ext.h diff --git a/extras/volume_id/volume_id/fat/fat.c b/extras/volume_id/volume_id/fat.c similarity index 99% rename from extras/volume_id/volume_id/fat/fat.c rename to extras/volume_id/volume_id/fat.c index 7c658fe5..58aa2aba 100644 --- a/extras/volume_id/volume_id/fat/fat.c +++ b/extras/volume_id/volume_id/fat.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "fat.h" #define FAT12_MAX 0xff5 diff --git a/extras/volume_id/volume_id/fat/fat.h b/extras/volume_id/volume_id/fat.h similarity index 100% rename from extras/volume_id/volume_id/fat/fat.h rename to extras/volume_id/volume_id/fat.h diff --git a/extras/volume_id/volume_id/hfs/hfs.c b/extras/volume_id/volume_id/hfs.c similarity index 99% rename from extras/volume_id/volume_id/hfs/hfs.c rename to extras/volume_id/volume_id/hfs.c index 905471cb..327461c6 100644 --- a/extras/volume_id/volume_id/hfs/hfs.c +++ b/extras/volume_id/volume_id/hfs.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "hfs.h" struct hfs_finder_info{ diff --git a/extras/volume_id/volume_id/hfs/hfs.h b/extras/volume_id/volume_id/hfs.h similarity index 100% rename from extras/volume_id/volume_id/hfs/hfs.h rename to extras/volume_id/volume_id/hfs.h diff --git a/extras/volume_id/volume_id/highpoint/highpoint.c b/extras/volume_id/volume_id/highpoint.c similarity index 96% rename from extras/volume_id/volume_id/highpoint/highpoint.c rename to extras/volume_id/volume_id/highpoint.c index b3014500..e13fd6de 100644 --- a/extras/volume_id/volume_id/highpoint/highpoint.c +++ b/extras/volume_id/volume_id/highpoint.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "highpoint.h" struct hpt37x { diff --git a/extras/volume_id/volume_id/highpoint/highpoint.h b/extras/volume_id/volume_id/highpoint.h similarity index 100% rename from extras/volume_id/volume_id/highpoint/highpoint.h rename to extras/volume_id/volume_id/highpoint.h diff --git a/extras/volume_id/volume_id/hpfs/hpfs.c b/extras/volume_id/volume_id/hpfs.c similarity index 96% rename from extras/volume_id/volume_id/hpfs/hpfs.c rename to extras/volume_id/volume_id/hpfs.c index 212e74ee..a8daea78 100644 --- a/extras/volume_id/volume_id/hpfs/hpfs.c +++ b/extras/volume_id/volume_id/hpfs.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "hpfs.h" struct hpfs_super diff --git a/extras/volume_id/volume_id/hpfs/hpfs.h b/extras/volume_id/volume_id/hpfs.h similarity index 100% rename from extras/volume_id/volume_id/hpfs/hpfs.h rename to extras/volume_id/volume_id/hpfs.h diff --git a/extras/volume_id/volume_id/iso9660/iso9660.c b/extras/volume_id/volume_id/iso9660.c similarity index 97% rename from extras/volume_id/volume_id/iso9660/iso9660.c rename to extras/volume_id/volume_id/iso9660.c index 1d7cfd50..ffccf609 100644 --- a/extras/volume_id/volume_id/iso9660/iso9660.c +++ b/extras/volume_id/volume_id/iso9660.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "iso9660.h" #define ISO_SUPERBLOCK_OFFSET 0x8000 diff --git a/extras/volume_id/volume_id/iso9660/iso9660.h b/extras/volume_id/volume_id/iso9660.h similarity index 100% rename from extras/volume_id/volume_id/iso9660/iso9660.h rename to extras/volume_id/volume_id/iso9660.h diff --git a/extras/volume_id/volume_id/jfs/jfs.c b/extras/volume_id/volume_id/jfs.c similarity index 96% rename from extras/volume_id/volume_id/jfs/jfs.c rename to extras/volume_id/volume_id/jfs.c index ab0b8308..ac4eab50 100644 --- a/extras/volume_id/volume_id/jfs/jfs.c +++ b/extras/volume_id/volume_id/jfs.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "jfs.h" struct jfs_super_block { diff --git a/extras/volume_id/volume_id/jfs/jfs.h b/extras/volume_id/volume_id/jfs.h similarity index 100% rename from extras/volume_id/volume_id/jfs/jfs.h rename to extras/volume_id/volume_id/jfs.h diff --git a/extras/volume_id/volume_id/linux_raid/linux_raid.c b/extras/volume_id/volume_id/linux_raid.c similarity index 97% rename from extras/volume_id/volume_id/linux_raid/linux_raid.c rename to extras/volume_id/volume_id/linux_raid.c index ca03030e..0ea8596a 100644 --- a/extras/volume_id/volume_id/linux_raid/linux_raid.c +++ b/extras/volume_id/volume_id/linux_raid.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "linux_raid.h" struct mdp_super_block { diff --git a/extras/volume_id/volume_id/linux_raid/linux_raid.h b/extras/volume_id/volume_id/linux_raid.h similarity index 100% rename from extras/volume_id/volume_id/linux_raid/linux_raid.h rename to extras/volume_id/volume_id/linux_raid.h diff --git a/extras/volume_id/volume_id/linux_swap/linux_swap.c b/extras/volume_id/volume_id/linux_swap.c similarity index 96% rename from extras/volume_id/volume_id/linux_swap/linux_swap.c rename to extras/volume_id/volume_id/linux_swap.c index 2fb16377..39a2c4aa 100644 --- a/extras/volume_id/volume_id/linux_swap/linux_swap.c +++ b/extras/volume_id/volume_id/linux_swap.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "linux_swap.h" struct swap_header_v1_2 { diff --git a/extras/volume_id/volume_id/linux_swap/linux_swap.h b/extras/volume_id/volume_id/linux_swap.h similarity index 100% rename from extras/volume_id/volume_id/linux_swap/linux_swap.h rename to extras/volume_id/volume_id/linux_swap.h diff --git a/extras/volume_id/volume_id/luks.c b/extras/volume_id/volume_id/luks.c new file mode 100644 index 00000000..20016927 --- /dev/null +++ b/extras/volume_id/volume_id/luks.c @@ -0,0 +1,106 @@ +/* + * volume_id - reads filesystem label and uuid + * + * Copyright (C) 2005 W. Michael Petullo + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "volume_id.h" +#include "util.h" +#include "logging.h" +#include "luks.h" + +/* from cryptsetup-luks internal.h */ +#define SECTOR_SHIFT 9 +#define SECTOR_SIZE (1 << SECTOR_SHIFT) + +/* from cryptsetup-luks luks.h */ +#define LUKS_CIPHERNAME_L 32 +#define LUKS_CIPHERMODE_L 32 +#define LUKS_HASHSPEC_L 32 +#define LUKS_DIGESTSIZE 20 /* since SHA1 */ +#define LUKS_SALTSIZE 32 +#define LUKS_NUMKEYS 8 + +/* from cryptsetup-luks luks.h */ +const unsigned char LUKS_MAGIC[] = {'L','U','K','S', 0xba, 0xbe}; +#define LUKS_MAGIC_L 6 + +/* from cryptsetup-luks luks.h */ +#define LUKS_PHDR_SIZE (sizeof(struct luks_phdr)/SECTOR_SIZE+1) + +/* from cryptsetup-luks luks.h */ +#define UUID_STRING_L 40 + +int volume_id_probe_luks(struct volume_id *id, __u64 off) +{ + /* from cryptsetup-luks luks.h */ + struct luks_phdr { + char magic[LUKS_MAGIC_L]; + uint16_t version; + char cipherName[LUKS_CIPHERNAME_L]; + char cipherMode[LUKS_CIPHERMODE_L]; + char hashSpec[LUKS_HASHSPEC_L]; + uint32_t payloadOffset; + uint32_t keyBytes; + char mkDigest[LUKS_DIGESTSIZE]; + char mkDigestSalt[LUKS_SALTSIZE]; + uint32_t mkDigestIterations; + char uuid[UUID_STRING_L]; + struct { + uint32_t active; + + /* parameters used for password processing */ + uint32_t passwordIterations; + char passwordSalt[LUKS_SALTSIZE]; + + /* parameters used for AF store/load */ + uint32_t keyMaterialOffset; + uint32_t stripes; + } keyblock[LUKS_NUMKEYS]; + } *header; + + header = (struct luks_phdr*) volume_id_get_buffer(id, off, LUKS_PHDR_SIZE); + + if (header == NULL) + return -1; + + if (memcmp(header->magic, LUKS_MAGIC, LUKS_MAGIC_L)) + return -1; + + volume_id_set_usage(id, VOLUME_ID_CRYPTO); + volume_id_set_uuid(id, header->uuid, UUID_DCE); + id->type = "crypto_LUKS"; + + return 0; +} diff --git a/extras/volume_id/volume_id/luks.h b/extras/volume_id/volume_id/luks.h new file mode 100644 index 00000000..180336f5 --- /dev/null +++ b/extras/volume_id/volume_id/luks.h @@ -0,0 +1,26 @@ +/* + * volume_id - reads filesystem label and uuid + * + * Copyright (C) 2005 W. Michael Petullo + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _VOLUME_ID_LUKS_ +#define _VOLUME_ID_LUKS_ + +extern int volume_id_probe_luks(struct volume_id *id, __u64 off); + +#endif diff --git a/extras/volume_id/volume_id/lvm/lvm.c b/extras/volume_id/volume_id/lvm.c similarity index 97% rename from extras/volume_id/volume_id/lvm/lvm.c rename to extras/volume_id/volume_id/lvm.c index ed1a83ae..bfc2ef23 100644 --- a/extras/volume_id/volume_id/lvm/lvm.c +++ b/extras/volume_id/volume_id/lvm.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "lvm.h" struct lvm1_super_block { diff --git a/extras/volume_id/volume_id/lvm/lvm.h b/extras/volume_id/volume_id/lvm.h similarity index 100% rename from extras/volume_id/volume_id/lvm/lvm.h rename to extras/volume_id/volume_id/lvm.h diff --git a/extras/volume_id/volume_id/mac/mac.c b/extras/volume_id/volume_id/mac.c similarity index 98% rename from extras/volume_id/volume_id/mac/mac.c rename to extras/volume_id/volume_id/mac.c index 895316d2..2e2db486 100644 --- a/extras/volume_id/volume_id/mac/mac.c +++ b/extras/volume_id/volume_id/mac.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "mac.h" struct mac_driver_desc { diff --git a/extras/volume_id/volume_id/mac/mac.h b/extras/volume_id/volume_id/mac.h similarity index 100% rename from extras/volume_id/volume_id/mac/mac.h rename to extras/volume_id/volume_id/mac.h diff --git a/extras/volume_id/volume_id/msdos/msdos.c b/extras/volume_id/volume_id/msdos.c similarity index 98% rename from extras/volume_id/volume_id/msdos/msdos.c rename to extras/volume_id/volume_id/msdos.c index a90b9efc..fc2f99d4 100644 --- a/extras/volume_id/volume_id/msdos/msdos.c +++ b/extras/volume_id/volume_id/msdos.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "msdos.h" struct msdos_partition_entry { diff --git a/extras/volume_id/volume_id/msdos/msdos.h b/extras/volume_id/volume_id/msdos.h similarity index 100% rename from extras/volume_id/volume_id/msdos/msdos.h rename to extras/volume_id/volume_id/msdos.h diff --git a/extras/volume_id/volume_id/ntfs/ntfs.c b/extras/volume_id/volume_id/ntfs.c similarity index 98% rename from extras/volume_id/volume_id/ntfs/ntfs.c rename to extras/volume_id/volume_id/ntfs.c index e46bc64b..84d6fbb8 100644 --- a/extras/volume_id/volume_id/ntfs/ntfs.c +++ b/extras/volume_id/volume_id/ntfs.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "ntfs.h" struct ntfs_super_block { diff --git a/extras/volume_id/volume_id/ntfs/ntfs.h b/extras/volume_id/volume_id/ntfs.h similarity index 100% rename from extras/volume_id/volume_id/ntfs/ntfs.h rename to extras/volume_id/volume_id/ntfs.h diff --git a/extras/volume_id/volume_id/reiserfs/reiserfs.c b/extras/volume_id/volume_id/reiserfs.c similarity index 97% rename from extras/volume_id/volume_id/reiserfs/reiserfs.c rename to extras/volume_id/volume_id/reiserfs.c index d54013e4..b74b8ae5 100644 --- a/extras/volume_id/volume_id/reiserfs/reiserfs.c +++ b/extras/volume_id/volume_id/reiserfs.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "reiserfs.h" struct reiserfs_super_block { diff --git a/extras/volume_id/volume_id/reiserfs/reiserfs.h b/extras/volume_id/volume_id/reiserfs.h similarity index 100% rename from extras/volume_id/volume_id/reiserfs/reiserfs.h rename to extras/volume_id/volume_id/reiserfs.h diff --git a/extras/volume_id/volume_id/romfs/romfs.c b/extras/volume_id/volume_id/romfs.c similarity index 96% rename from extras/volume_id/volume_id/romfs/romfs.c rename to extras/volume_id/volume_id/romfs.c index c04dc98f..fe5e5a48 100644 --- a/extras/volume_id/volume_id/romfs/romfs.c +++ b/extras/volume_id/volume_id/romfs.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "romfs.h" struct romfs_super { diff --git a/extras/volume_id/volume_id/romfs/romfs.h b/extras/volume_id/volume_id/romfs.h similarity index 100% rename from extras/volume_id/volume_id/romfs/romfs.h rename to extras/volume_id/volume_id/romfs.h diff --git a/extras/volume_id/volume_id/sysv/sysv.c b/extras/volume_id/volume_id/sysv.c similarity index 97% rename from extras/volume_id/volume_id/sysv/sysv.c rename to extras/volume_id/volume_id/sysv.c index 313ac173..6c4408d8 100644 --- a/extras/volume_id/volume_id/sysv/sysv.c +++ b/extras/volume_id/volume_id/sysv.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "sysv.h" #define SYSV_NICINOD 100 diff --git a/extras/volume_id/volume_id/sysv/sysv.h b/extras/volume_id/volume_id/sysv.h similarity index 100% rename from extras/volume_id/volume_id/sysv/sysv.h rename to extras/volume_id/volume_id/sysv.h diff --git a/extras/volume_id/volume_id/udf/udf.c b/extras/volume_id/volume_id/udf.c similarity index 98% rename from extras/volume_id/volume_id/udf/udf.c rename to extras/volume_id/volume_id/udf.c index 79d25ad8..06b52154 100644 --- a/extras/volume_id/volume_id/udf/udf.c +++ b/extras/volume_id/volume_id/udf.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "udf.h" struct volume_descriptor { diff --git a/extras/volume_id/volume_id/udf/udf.h b/extras/volume_id/volume_id/udf.h similarity index 100% rename from extras/volume_id/volume_id/udf/udf.h rename to extras/volume_id/volume_id/udf.h diff --git a/extras/volume_id/volume_id/ufs/ufs.c b/extras/volume_id/volume_id/ufs.c similarity index 98% rename from extras/volume_id/volume_id/ufs/ufs.c rename to extras/volume_id/volume_id/ufs.c index 12672ffe..37e74aee 100644 --- a/extras/volume_id/volume_id/ufs/ufs.c +++ b/extras/volume_id/volume_id/ufs.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "ufs.h" struct ufs_super_block { diff --git a/extras/volume_id/volume_id/ufs/ufs.h b/extras/volume_id/volume_id/ufs.h similarity index 100% rename from extras/volume_id/volume_id/ufs/ufs.h rename to extras/volume_id/volume_id/ufs.h diff --git a/extras/volume_id/volume_id/util.c b/extras/volume_id/volume_id/util.c index 0cd2eade..6159a599 100644 --- a/extras/volume_id/volume_id/util.c +++ b/extras/volume_id/volume_id/util.c @@ -53,6 +53,8 @@ static char *usage_to_string(enum volume_id_usage usage_id) return "raid"; case VOLUME_ID_DISKLABEL: return "disklabel"; + case VOLUME_ID_CRYPTO: + return "crypto"; case VOLUME_ID_UNPROBED: return "unprobed"; case VOLUME_ID_UNUSED: diff --git a/extras/volume_id/volume_id/volume_id.c b/extras/volume_id/volume_id/volume_id.c index 95f7f5b1..f93cc911 100644 --- a/extras/volume_id/volume_id/volume_id.c +++ b/extras/volume_id/volume_id/volume_id.c @@ -41,25 +41,28 @@ #include "logging.h" #include "util.h" -#include "ext/ext.h" -#include "reiserfs/reiserfs.h" -#include "fat/fat.h" -#include "hfs/hfs.h" -#include "jfs/jfs.h" -#include "xfs/xfs.h" -#include "ufs/ufs.h" -#include "ntfs/ntfs.h" -#include "iso9660/iso9660.h" -#include "udf/udf.h" -#include "highpoint/highpoint.h" -#include "linux_swap/linux_swap.h" -#include "linux_raid/linux_raid.h" -#include "lvm/lvm.h" -#include "cramfs/cramfs.h" -#include "hpfs/hpfs.h" -#include "romfs/romfs.h" -#include "mac/mac.h" -#include "msdos/msdos.h" +#include "ext.h" +#include "reiserfs.h" +#include "fat.h" +#include "hfs.h" +#include "jfs.h" +#include "xfs.h" +#include "ufs.h" +#include "ntfs.h" +#include "iso9660.h" +#include "udf.h" +#include "luks.h" +#include "highpoint.h" +#include "linux_swap.h" +#include "linux_raid.h" +#include "lvm.h" +#include "cramfs.h" +#include "hpfs.h" +#include "romfs.h" +#include "sysv.h" +#include "luks.h" +#include "mac.h" +#include "msdos.h" int volume_id_probe_all(struct volume_id *id, unsigned long long off, unsigned long long size) { @@ -79,6 +82,9 @@ int volume_id_probe_all(struct volume_id *id, unsigned long long off, unsigned l if (volume_id_probe_highpoint_ataraid(id, off) == 0) goto exit; + if (volume_id_probe_luks(id, off) == 0) + goto exit; + /* signature in the first block, only small buffer needed */ if (volume_id_probe_vfat(id, off) == 0) goto exit; @@ -128,6 +134,9 @@ int volume_id_probe_all(struct volume_id *id, unsigned long long off, unsigned l if (volume_id_probe_hpfs(id, off) == 0) goto exit; + if (volume_id_probe_sysv(id, off) == 0) + goto exit; + return -1; exit: diff --git a/extras/volume_id/volume_id/volume_id.h b/extras/volume_id/volume_id/volume_id.h index 5b845602..c22a5e60 100644 --- a/extras/volume_id/volume_id/volume_id.h +++ b/extras/volume_id/volume_id/volume_id.h @@ -21,7 +21,7 @@ #ifndef _VOLUME_ID_H_ #define _VOLUME_ID_H_ -#define VOLUME_ID_VERSION 34 +#define VOLUME_ID_VERSION 35 #define VOLUME_ID_LABEL_SIZE 64 #define VOLUME_ID_UUID_SIZE 16 @@ -38,6 +38,7 @@ enum volume_id_usage { VOLUME_ID_PARTITIONTABLE, VOLUME_ID_RAID, VOLUME_ID_DISKLABEL, + VOLUME_ID_CRYPTO, }; struct volume_id_partition { diff --git a/extras/volume_id/volume_id/xfs/xfs.c b/extras/volume_id/volume_id/xfs.c similarity index 96% rename from extras/volume_id/volume_id/xfs/xfs.c rename to extras/volume_id/volume_id/xfs.c index efbe06ec..12a89aaf 100644 --- a/extras/volume_id/volume_id/xfs/xfs.c +++ b/extras/volume_id/volume_id/xfs.c @@ -34,9 +34,9 @@ #include #include -#include "../volume_id.h" -#include "../logging.h" -#include "../util.h" +#include "volume_id.h" +#include "logging.h" +#include "util.h" #include "xfs.h" struct xfs_super_block { diff --git a/extras/volume_id/volume_id/xfs/xfs.h b/extras/volume_id/volume_id/xfs.h similarity index 100% rename from extras/volume_id/volume_id/xfs/xfs.h rename to extras/volume_id/volume_id/xfs.h -- 2.39.5