Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
2006-08-12 15:34:15 +00:00
|
|
|
* Copyright (c) 2006 Tobias Reifenberger
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2006-02-01 12:06:01 +00:00
|
|
|
*
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
|
|
|
#include <geom/geom.h>
|
|
|
|
#include <geom/label/g_label.h>
|
2006-08-12 15:34:15 +00:00
|
|
|
#include <geom/label/g_label_msdosfs.h>
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
|
|
|
|
#define G_LABEL_MSDOSFS_DIR "msdosfs"
|
2006-08-12 15:34:15 +00:00
|
|
|
#define LABEL_NO_NAME "NO NAME "
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size)
|
|
|
|
{
|
|
|
|
struct g_provider *pp;
|
2006-08-12 15:34:15 +00:00
|
|
|
FAT_BSBPB *pfat_bsbpb;
|
|
|
|
FAT32_BSBPB *pfat32_bsbpb;
|
|
|
|
FAT_DES *pfat_entry;
|
|
|
|
uint8_t *sector0, *sector;
|
|
|
|
uint32_t i;
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
|
|
|
|
g_topology_assert_not();
|
|
|
|
pp = cp->provider;
|
2006-08-12 15:34:15 +00:00
|
|
|
sector0 = NULL;
|
|
|
|
sector = NULL;
|
|
|
|
bzero(label, size);
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
|
2006-08-12 15:34:15 +00:00
|
|
|
/* Check if the sector size of the medium is a valid FAT sector size. */
|
|
|
|
switch(pp->sectorsize) {
|
|
|
|
case 512:
|
|
|
|
case 1024:
|
|
|
|
case 2048:
|
|
|
|
case 4096:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_LABEL_DEBUG(1, "MSDOSFS: %s: sector size %d not compatible.",
|
|
|
|
pp->name, pp->sectorsize);
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
return;
|
2006-08-12 15:34:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Load 1st sector with boot sector and boot parameter block. */
|
|
|
|
sector0 = (uint8_t *)g_read_data(cp, 0, pp->sectorsize, NULL);
|
|
|
|
if (sector0 == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Check for the FAT boot sector signature. */
|
|
|
|
if (sector0[510] != 0x55 || sector0[511] != 0xaa) {
|
|
|
|
G_LABEL_DEBUG(1, "MSDOSFS: %s: no FAT signature found.",
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
pp->name);
|
2006-08-12 15:34:15 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test if this is really a FAT volume and determine the FAT type.
|
|
|
|
*/
|
|
|
|
|
|
|
|
pfat_bsbpb = (FAT_BSBPB *)sector0;
|
|
|
|
pfat32_bsbpb = (FAT32_BSBPB *)sector0;
|
|
|
|
|
|
|
|
if (UINT16BYTES(pfat_bsbpb->BPB_FATSz16) != 0) {
|
|
|
|
/*
|
|
|
|
* If the BPB_FATSz16 field is not zero and the string "FAT" is
|
|
|
|
* at the right place, this should be a FAT12 or FAT16 volume.
|
|
|
|
*/
|
|
|
|
if (strncmp(pfat_bsbpb->BS_FilSysType, "FAT", 3) != 0) {
|
|
|
|
G_LABEL_DEBUG(1,
|
|
|
|
"MSDOSFS: %s: FAT12/16 volume not valid.",
|
|
|
|
pp->name);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
G_LABEL_DEBUG(1, "MSDOSFS: %s: FAT12/FAT16 volume detected.",
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
pp->name);
|
2006-08-12 15:34:15 +00:00
|
|
|
|
|
|
|
/* A volume with no name should have "NO NAME " as label. */
|
|
|
|
if (strncmp(pfat_bsbpb->BS_VolLab, LABEL_NO_NAME,
|
|
|
|
sizeof(pfat_bsbpb->BS_VolLab)) == 0) {
|
|
|
|
G_LABEL_DEBUG(1,
|
|
|
|
"MSDOSFS: %s: FAT12/16 volume has no name.",
|
|
|
|
pp->name);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
strlcpy(label, pfat_bsbpb->BS_VolLab,
|
|
|
|
MIN(size, sizeof(pfat_bsbpb->BS_VolLab) + 1));
|
|
|
|
} else if (UINT32BYTES(pfat32_bsbpb->BPB_FATSz32) != 0) {
|
|
|
|
uint32_t fat_FirstDataSector, fat_BytesPerSector, offset;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the BPB_FATSz32 field is not zero and the string "FAT" is
|
|
|
|
* at the right place, this should be a FAT32 volume.
|
|
|
|
*/
|
|
|
|
if (strncmp(pfat32_bsbpb->BS_FilSysType, "FAT", 3) != 0) {
|
|
|
|
G_LABEL_DEBUG(1, "MSDOSFS: %s: FAT32 volume not valid.",
|
|
|
|
pp->name);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
G_LABEL_DEBUG(1, "MSDOSFS: %s: FAT32 volume detected.",
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
pp->name);
|
2006-08-12 15:34:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the volume label is not "NO NAME " we're done.
|
|
|
|
*/
|
|
|
|
if (strncmp(pfat32_bsbpb->BS_VolLab, LABEL_NO_NAME,
|
|
|
|
sizeof(pfat32_bsbpb->BS_VolLab)) != 0) {
|
|
|
|
strlcpy(label, pfat32_bsbpb->BS_VolLab,
|
|
|
|
MIN(size, sizeof(pfat32_bsbpb->BS_VolLab) + 1));
|
|
|
|
goto endofchecks;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the volume label "NO NAME " is in the boot sector, the
|
|
|
|
* label of FAT32 volumes may be stored as a special entry in
|
|
|
|
* the root directory.
|
|
|
|
*/
|
|
|
|
fat_FirstDataSector =
|
|
|
|
UINT16BYTES(pfat32_bsbpb->BPB_RsvdSecCnt) +
|
|
|
|
(pfat32_bsbpb->BPB_NumFATs *
|
|
|
|
UINT32BYTES(pfat32_bsbpb->BPB_FATSz32));
|
|
|
|
fat_BytesPerSector = UINT16BYTES(pfat32_bsbpb->BPB_BytsPerSec);
|
|
|
|
|
|
|
|
G_LABEL_DEBUG(2,
|
|
|
|
"MSDOSFS: FAT_FirstDataSector=0x%x, FAT_BytesPerSector=%d",
|
|
|
|
fat_FirstDataSector, fat_BytesPerSector);
|
|
|
|
|
|
|
|
for (offset = fat_BytesPerSector * fat_FirstDataSector;;
|
|
|
|
offset += fat_BytesPerSector) {
|
|
|
|
sector = (uint8_t *)g_read_data(cp, offset,
|
|
|
|
fat_BytesPerSector, NULL);
|
|
|
|
if (sector == NULL)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
pfat_entry = (FAT_DES *)sector;
|
|
|
|
do {
|
|
|
|
/* No more entries available. */
|
|
|
|
if (pfat_entry->DIR_Name[0] == 0) {
|
|
|
|
G_LABEL_DEBUG(1, "MSDOSFS: %s: "
|
|
|
|
"FAT32 volume has no name.",
|
|
|
|
pp->name);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip empty or long name entries. */
|
|
|
|
if (pfat_entry->DIR_Name[0] == 0xe5 ||
|
|
|
|
(pfat_entry->DIR_Attr &
|
|
|
|
FAT_DES_ATTR_LONG_NAME) ==
|
|
|
|
FAT_DES_ATTR_LONG_NAME) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The name of the entry is the volume label if
|
|
|
|
* ATTR_VOLUME_ID is set.
|
|
|
|
*/
|
|
|
|
if (pfat_entry->DIR_Attr &
|
|
|
|
FAT_DES_ATTR_VOLUME_ID) {
|
|
|
|
strlcpy(label, pfat_entry->DIR_Name,
|
|
|
|
MIN(size,
|
|
|
|
sizeof(pfat_bsbpb->BS_VolLab) + 1));
|
|
|
|
goto endofchecks;
|
|
|
|
}
|
|
|
|
} while((uint8_t *)(++pfat_entry) <
|
|
|
|
(uint8_t *)(sector + fat_BytesPerSector));
|
|
|
|
g_free(sector);
|
|
|
|
}
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
} else {
|
2006-08-12 15:34:15 +00:00
|
|
|
G_LABEL_DEBUG(1, "MSDOSFS: %s: no FAT volume detected.",
|
|
|
|
pp->name);
|
|
|
|
goto error;
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
}
|
2006-08-12 15:34:15 +00:00
|
|
|
|
|
|
|
endofchecks:
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
for (i = size - 1; i > 0; i--) {
|
|
|
|
if (label[i] == '\0')
|
|
|
|
continue;
|
|
|
|
else if (label[i] == ' ')
|
|
|
|
label[i] = '\0';
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2006-08-12 15:34:15 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (sector0 != NULL)
|
|
|
|
g_free(sector0);
|
|
|
|
if (sector != NULL)
|
|
|
|
g_free(sector);
|
Introduce GEOM_LABEL class.
This class is used for detecting volume labels on file systems:
UFS, MSDOSFS (FAT12, FAT16, FAT32) and ISO9660.
It also provide native labelization (there is no need for file system).
g_label_ufs.c is based on geom_vol_ffs from Gordon Tetlow.
g_label_msdos.c and g_label_iso9660.c are probably hacks, I just found
where volume labels are stored and I use those offsets here,
but with this class it should be easy to do it as it should be done by
someone who know how.
Implementing volume labels detection for other file systems also should
be trivial.
New providers are created in those directories:
/dev/ufs/ (UFS1, UFS2)
/dev/msdosfs/ (FAT12, FAT16, FAT32)
/dev/iso9660/ (ISO9660)
/dev/label/ (native labels, configured with glabel(8))
Manual page cleanups and some comments inside were submitted by
Simon L. Nielsen, who was, as always, very helpful. Thanks!
2004-07-02 19:40:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct g_label_desc g_label_msdosfs = {
|
|
|
|
.ld_taste = g_label_msdosfs_taste,
|
|
|
|
.ld_dir = G_LABEL_MSDOSFS_DIR
|
|
|
|
};
|