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
|
|
|
/*-
|
2017-11-27 15:17:37 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2005-02-27 23:07:47 +00:00
|
|
|
* Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
|
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$");
|
|
|
|
|
2014-04-06 02:44:37 +00:00
|
|
|
#include "opt_geom.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
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/bio.h>
|
2012-12-22 13:43:12 +00:00
|
|
|
#include <sys/ctype.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
|
|
|
#include <sys/malloc.h>
|
2006-08-12 15:30:24 +00:00
|
|
|
#include <sys/libkern.h>
|
2012-12-22 13:43:12 +00:00
|
|
|
#include <sys/sbuf.h>
|
2015-06-18 21:55:55 +00:00
|
|
|
#include <sys/stddef.h>
|
2011-02-25 10:24:35 +00:00
|
|
|
#include <sys/sysctl.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
|
|
|
#include <geom/geom.h>
|
2019-08-07 19:28:35 +00:00
|
|
|
#include <geom/geom_dbg.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
|
|
|
#include <geom/geom_slice.h>
|
|
|
|
#include <geom/label/g_label.h>
|
|
|
|
|
2011-02-25 10:24:35 +00:00
|
|
|
FEATURE(geom_label, "GEOM labeling support");
|
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
|
|
|
|
|
|
|
SYSCTL_DECL(_kern_geom);
|
2020-02-26 14:26:36 +00:00
|
|
|
SYSCTL_NODE(_kern_geom, OID_AUTO, label, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
|
|
|
|
"GEOM_LABEL stuff");
|
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
|
|
|
u_int g_label_debug = 0;
|
2014-06-28 03:56:17 +00:00
|
|
|
SYSCTL_UINT(_kern_geom_label, OID_AUTO, debug, CTLFLAG_RWTUN, &g_label_debug, 0,
|
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
|
|
|
"Debug level");
|
|
|
|
|
2004-10-14 07:46:13 +00:00
|
|
|
static int g_label_destroy_geom(struct gctl_req *req, struct g_class *mp,
|
|
|
|
struct g_geom *gp);
|
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 int g_label_destroy(struct g_geom *gp, boolean_t force);
|
|
|
|
static struct g_geom *g_label_taste(struct g_class *mp, struct g_provider *pp,
|
|
|
|
int flags __unused);
|
2020-07-26 00:44:59 +00:00
|
|
|
static void g_label_generic_taste(struct g_consumer *, char *, size_t);
|
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_config(struct gctl_req *req, struct g_class *mp,
|
|
|
|
const char *verb);
|
|
|
|
|
2020-07-26 00:44:59 +00:00
|
|
|
#define G_LABEL_DIRPREFIX "label/"
|
|
|
|
|
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
|
|
|
struct g_class g_label_class = {
|
|
|
|
.name = G_LABEL_CLASS_NAME,
|
2004-08-08 07:57:53 +00:00
|
|
|
.version = G_VERSION,
|
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
|
|
|
.ctlreq = g_label_config,
|
2004-10-14 07:46:13 +00:00
|
|
|
.taste = g_label_taste,
|
|
|
|
.destroy_geom = g_label_destroy_geom
|
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
|
|
|
};
|
|
|
|
|
2020-07-26 00:44:59 +00:00
|
|
|
static struct g_label_desc g_label_generic = {
|
|
|
|
.ld_taste = g_label_generic_taste,
|
|
|
|
.ld_dirprefix = G_LABEL_DIRPREFIX,
|
|
|
|
.ld_enabled = 1
|
|
|
|
};
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* To add a new file system where you want to look for volume labels,
|
|
|
|
* you have to:
|
2005-08-12 00:34:45 +00:00
|
|
|
* 1. Add a file g_label_<file system>.c which implements labels recognition.
|
|
|
|
* 2. Add an 'extern const struct g_label_desc g_label_<file system>;' into
|
|
|
|
* g_label.h file.
|
|
|
|
* 3. Add an element to the table below '&g_label_<file system>,'.
|
|
|
|
* 4. Add your file to sys/conf/files.
|
|
|
|
* 5. Add your file to sys/modules/geom/geom_label/Makefile.
|
|
|
|
* 6. Add your file system to manual page sbin/geom/class/label/glabel.8.
|
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_labels[] = {
|
2014-04-06 02:44:37 +00:00
|
|
|
&g_label_gpt,
|
|
|
|
&g_label_gpt_uuid,
|
|
|
|
#ifdef GEOM_LABEL
|
2009-03-25 20:38:57 +00:00
|
|
|
&g_label_ufs_id,
|
|
|
|
&g_label_ufs_volume,
|
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_label_iso9660,
|
|
|
|
&g_label_msdosfs,
|
2005-08-12 00:27:45 +00:00
|
|
|
&g_label_ext2fs,
|
|
|
|
&g_label_reiserfs,
|
2012-10-18 22:18:11 +00:00
|
|
|
&g_label_ntfs,
|
2013-04-15 16:09:24 +00:00
|
|
|
&g_label_disk_ident,
|
2019-03-24 19:11:45 +00:00
|
|
|
&g_label_flashmap,
|
2014-04-06 02:44:37 +00:00
|
|
|
#endif
|
2020-07-26 00:44:59 +00:00
|
|
|
&g_label_generic,
|
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
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2015-06-18 21:55:55 +00:00
|
|
|
void
|
|
|
|
g_label_rtrim(char *label, size_t size)
|
|
|
|
{
|
|
|
|
ptrdiff_t i;
|
|
|
|
|
|
|
|
for (i = size - 1; i >= 0; i--) {
|
|
|
|
if (label[i] == '\0')
|
|
|
|
continue;
|
|
|
|
else if (label[i] == ' ')
|
|
|
|
label[i] = '\0';
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2004-10-14 07:46:13 +00:00
|
|
|
static int
|
|
|
|
g_label_destroy_geom(struct gctl_req *req __unused, struct g_class *mp,
|
|
|
|
struct g_geom *gp __unused)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: Unloading a class which is using geom_slice:1.56 is currently
|
|
|
|
* XXX: broken, so we deny unloading when we have geoms.
|
|
|
|
*/
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
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
|
2006-02-18 11:24:00 +00:00
|
|
|
g_label_orphan(struct g_consumer *cp)
|
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
|
|
|
{
|
|
|
|
|
2009-05-30 22:31:52 +00:00
|
|
|
G_LABEL_DEBUG(1, "Label %s removed.",
|
2006-02-18 11:24:00 +00:00
|
|
|
LIST_FIRST(&cp->geom->provider)->name);
|
|
|
|
g_slice_orphan(cp);
|
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
|
2006-02-18 11:24:00 +00:00
|
|
|
g_label_spoiled(struct g_consumer *cp)
|
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
|
|
|
{
|
|
|
|
|
2009-05-30 22:31:52 +00:00
|
|
|
G_LABEL_DEBUG(1, "Label %s removed.",
|
2006-02-18 11:24:00 +00:00
|
|
|
LIST_FIRST(&cp->geom->provider)->name);
|
|
|
|
g_slice_spoiled(cp);
|
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
|
|
|
}
|
|
|
|
|
2013-10-18 09:14:19 +00:00
|
|
|
static void
|
|
|
|
g_label_resize(struct g_consumer *cp)
|
|
|
|
{
|
|
|
|
|
|
|
|
G_LABEL_DEBUG(1, "Label %s resized.",
|
|
|
|
LIST_FIRST(&cp->geom->provider)->name);
|
|
|
|
|
|
|
|
g_slice_config(cp->geom, 0, G_SLICE_CONFIG_FORCE, (off_t)0,
|
2013-10-19 08:20:00 +00:00
|
|
|
cp->provider->mediasize, cp->provider->sectorsize, "notused");
|
2013-10-18 09:14:19 +00:00
|
|
|
}
|
|
|
|
|
2006-08-12 15:30:24 +00:00
|
|
|
static int
|
|
|
|
g_label_is_name_ok(const char *label)
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
|
2010-12-01 19:24:07 +00:00
|
|
|
/* Check if the label starts from ../ */
|
2006-08-12 15:30:24 +00:00
|
|
|
if (strncmp(label, "../", 3) == 0)
|
|
|
|
return (0);
|
2010-12-01 19:24:07 +00:00
|
|
|
/* Check if the label contains /../ */
|
2006-08-12 15:30:24 +00:00
|
|
|
if (strstr(label, "/../") != NULL)
|
|
|
|
return (0);
|
2010-12-01 19:24:07 +00:00
|
|
|
/* Check if the label ends at ../ */
|
2006-08-12 15:30:24 +00:00
|
|
|
if ((s = strstr(label, "/..")) != NULL && s[3] == '\0')
|
|
|
|
return (0);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2012-12-22 13:43:12 +00:00
|
|
|
static void
|
|
|
|
g_label_mangle_name(char *label, size_t size)
|
|
|
|
{
|
|
|
|
struct sbuf *sb;
|
|
|
|
const u_char *c;
|
2020-01-18 03:33:44 +00:00
|
|
|
size_t len, i;
|
|
|
|
|
|
|
|
/* Trim trailing whitespace. */
|
|
|
|
len = strlen(label);
|
|
|
|
for (i = len; i > 0; i--) {
|
|
|
|
if (isspace(label[i - 1]))
|
|
|
|
label[i - 1] = '\0';
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (*label == '\0')
|
|
|
|
return;
|
|
|
|
|
2012-12-22 13:43:12 +00:00
|
|
|
sb = sbuf_new(NULL, NULL, size, SBUF_FIXEDLEN);
|
|
|
|
for (c = label; *c != '\0'; c++) {
|
2020-01-18 03:33:44 +00:00
|
|
|
/* Trim leading whitespace. */
|
|
|
|
if (isspace(*c) && sbuf_len(sb) == 0)
|
|
|
|
continue;
|
2012-12-22 13:43:12 +00:00
|
|
|
if (!isprint(*c) || isspace(*c) || *c =='"' || *c == '%')
|
|
|
|
sbuf_printf(sb, "%%%02X", *c);
|
|
|
|
else
|
|
|
|
sbuf_putc(sb, *c);
|
|
|
|
}
|
|
|
|
if (sbuf_finish(sb) != 0)
|
|
|
|
label[0] = '\0';
|
|
|
|
else
|
|
|
|
strlcpy(label, sbuf_data(sb), size);
|
|
|
|
sbuf_delete(sb);
|
|
|
|
}
|
|
|
|
|
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 struct g_geom *
|
|
|
|
g_label_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
|
2020-07-26 00:44:59 +00:00
|
|
|
const char *label, const char *dirprefix, off_t mediasize)
|
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
|
|
|
{
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_provider *pp2;
|
|
|
|
struct g_consumer *cp;
|
|
|
|
char name[64];
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
2006-08-12 15:30:24 +00:00
|
|
|
if (!g_label_is_name_ok(label)) {
|
|
|
|
G_LABEL_DEBUG(0, "%s contains suspicious label, skipping.",
|
|
|
|
pp->name);
|
|
|
|
G_LABEL_DEBUG(1, "%s suspicious label is: %s", pp->name, label);
|
2010-12-01 19:24:07 +00:00
|
|
|
if (req != NULL)
|
|
|
|
gctl_error(req, "Label name %s is invalid.", label);
|
2006-08-12 15:30:24 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
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
|
|
|
gp = NULL;
|
|
|
|
cp = NULL;
|
2020-07-26 00:44:59 +00:00
|
|
|
if (snprintf(name, sizeof(name), "%s%s", dirprefix, label) >= sizeof(name)) {
|
2018-01-27 12:28:52 +00:00
|
|
|
if (req != NULL)
|
|
|
|
gctl_error(req, "Label name %s is too long.", label);
|
|
|
|
return (NULL);
|
|
|
|
}
|
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
|
|
|
LIST_FOREACH(gp, &mp->geom, geom) {
|
|
|
|
pp2 = LIST_FIRST(&gp->provider);
|
|
|
|
if (pp2 == NULL)
|
|
|
|
continue;
|
2011-05-04 12:59:11 +00:00
|
|
|
if ((pp2->flags & G_PF_ORPHAN) != 0)
|
|
|
|
continue;
|
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
|
|
|
if (strcmp(pp2->name, name) == 0) {
|
|
|
|
G_LABEL_DEBUG(1, "Label %s(%s) already exists (%s).",
|
|
|
|
label, name, pp->name);
|
|
|
|
if (req != NULL) {
|
|
|
|
gctl_error(req, "Provider %s already exists.",
|
|
|
|
name);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gp = g_slice_new(mp, 1, pp, &cp, NULL, 0, NULL);
|
|
|
|
if (gp == NULL) {
|
|
|
|
G_LABEL_DEBUG(0, "Cannot create slice %s.", label);
|
|
|
|
if (req != NULL)
|
|
|
|
gctl_error(req, "Cannot create slice %s.", label);
|
|
|
|
return (NULL);
|
|
|
|
}
|
2006-02-18 11:24:00 +00:00
|
|
|
gp->orphan = g_label_orphan;
|
|
|
|
gp->spoiled = g_label_spoiled;
|
2013-10-18 09:14:19 +00:00
|
|
|
gp->resize = g_label_resize;
|
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_access(cp, -1, 0, 0);
|
|
|
|
g_slice_config(gp, 0, G_SLICE_CONFIG_SET, (off_t)0, mediasize,
|
2012-11-20 12:32:18 +00:00
|
|
|
pp->sectorsize, "%s", name);
|
2009-05-30 22:31:52 +00:00
|
|
|
G_LABEL_DEBUG(1, "Label for provider %s is %s.", pp->name, 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
|
|
|
return (gp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
g_label_destroy(struct g_geom *gp, boolean_t force)
|
|
|
|
{
|
|
|
|
struct g_provider *pp;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
pp = LIST_FIRST(&gp->provider);
|
|
|
|
if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) {
|
|
|
|
if (force) {
|
|
|
|
G_LABEL_DEBUG(0, "Provider %s is still open, so it "
|
|
|
|
"can't be definitely removed.", pp->name);
|
|
|
|
} else {
|
|
|
|
G_LABEL_DEBUG(1,
|
|
|
|
"Provider %s is still open (r%dw%de%d).", pp->name,
|
|
|
|
pp->acr, pp->acw, pp->ace);
|
|
|
|
return (EBUSY);
|
|
|
|
}
|
2010-05-31 09:10:39 +00:00
|
|
|
} else if (pp != NULL)
|
|
|
|
G_LABEL_DEBUG(1, "Label %s removed.", pp->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
|
|
|
g_slice_spoiled(LIST_FIRST(&gp->consumer));
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
g_label_read_metadata(struct g_consumer *cp, struct g_label_metadata *md)
|
|
|
|
{
|
|
|
|
struct g_provider *pp;
|
|
|
|
u_char *buf;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
pp = cp->provider;
|
2021-09-07 13:46:58 +00:00
|
|
|
if (pp->sectorsize < sizeof(*md))
|
|
|
|
return (EINVAL);
|
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
|
|
|
buf = g_read_data(cp, pp->mediasize - pp->sectorsize, pp->sectorsize,
|
|
|
|
&error);
|
|
|
|
if (buf == NULL)
|
|
|
|
return (error);
|
|
|
|
/* Decode metadata. */
|
|
|
|
label_metadata_decode(buf, md);
|
|
|
|
g_free(buf);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2006-02-18 11:24:00 +00:00
|
|
|
static void
|
|
|
|
g_label_orphan_taste(struct g_consumer *cp __unused)
|
|
|
|
{
|
|
|
|
|
|
|
|
KASSERT(1 == 0, ("%s called?", __func__));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_label_start_taste(struct bio *bp __unused)
|
|
|
|
{
|
|
|
|
|
|
|
|
KASSERT(1 == 0, ("%s called?", __func__));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
g_label_access_taste(struct g_provider *pp __unused, int dr __unused,
|
|
|
|
int dw __unused, int de __unused)
|
|
|
|
{
|
|
|
|
|
|
|
|
KASSERT(1 == 0, ("%s called", __func__));
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
2020-07-26 00:44:59 +00:00
|
|
|
static void
|
|
|
|
g_label_generic_taste(struct g_consumer *cp, char *label, size_t size)
|
|
|
|
{
|
|
|
|
struct g_provider *pp;
|
|
|
|
struct g_label_metadata md;
|
|
|
|
|
|
|
|
g_topology_assert_not();
|
|
|
|
label[0] = '\0';
|
|
|
|
pp = cp->provider;
|
|
|
|
|
|
|
|
if (g_label_read_metadata(cp, &md) != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (strcmp(md.md_magic, G_LABEL_MAGIC) != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (md.md_version > G_LABEL_VERSION) {
|
|
|
|
printf("geom_label.ko module is too old to handle %s.\n",
|
|
|
|
pp->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Backward compatibility: there was no md_provsize field in
|
|
|
|
* earlier versions of metadata, so only check if we have it.
|
|
|
|
*/
|
|
|
|
if (md.md_version >= 2 && md.md_provsize != pp->mediasize)
|
|
|
|
return;
|
|
|
|
|
|
|
|
strlcpy(label, md.md_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
|
|
|
static struct g_geom *
|
|
|
|
g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
|
|
|
|
{
|
|
|
|
struct g_consumer *cp;
|
|
|
|
struct g_geom *gp;
|
2020-07-26 00:44:59 +00:00
|
|
|
off_t mediasize;
|
2004-08-09 11:14:25 +00:00
|
|
|
int 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_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name);
|
|
|
|
g_topology_assert();
|
|
|
|
|
2004-07-13 12:01:11 +00:00
|
|
|
G_LABEL_DEBUG(2, "Tasting %s.", pp->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
|
|
|
|
2020-06-06 14:19:16 +00:00
|
|
|
/* Skip providers that are already open for writing. */
|
|
|
|
if (pp->acw > 0)
|
|
|
|
return (NULL);
|
|
|
|
|
2022-11-09 02:59:50 +00:00
|
|
|
/* Skip broken disks that don't set their sector size */
|
|
|
|
if (pp->sectorsize == 0)
|
|
|
|
return (NULL);
|
|
|
|
|
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
|
|
|
if (strcmp(pp->geom->class->name, mp->name) == 0)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
gp = g_new_geomf(mp, "label:taste");
|
2006-02-18 11:24:00 +00:00
|
|
|
gp->start = g_label_start_taste;
|
|
|
|
gp->access = g_label_access_taste;
|
|
|
|
gp->orphan = g_label_orphan_taste;
|
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
|
|
|
cp = g_new_consumer(gp);
|
2022-01-28 19:22:41 +00:00
|
|
|
cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
|
2020-10-18 16:24:08 +00:00
|
|
|
if (g_attach(cp, pp) != 0)
|
|
|
|
goto end2;
|
2004-08-09 11:14:25 +00:00
|
|
|
if (g_access(cp, 1, 0, 0) != 0)
|
|
|
|
goto end;
|
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 = 0; g_labels[i] != NULL; i++) {
|
2013-04-15 16:09:24 +00:00
|
|
|
char label[128];
|
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
|
|
|
|
2009-11-28 11:57:43 +00:00
|
|
|
if (g_labels[i]->ld_enabled == 0)
|
|
|
|
continue;
|
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_unlock();
|
|
|
|
g_labels[i]->ld_taste(cp, label, sizeof(label));
|
2012-12-22 13:43:12 +00:00
|
|
|
g_label_mangle_name(label, sizeof(label));
|
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_lock();
|
|
|
|
if (label[0] == '\0')
|
|
|
|
continue;
|
2020-07-26 00:44:59 +00:00
|
|
|
if (g_labels[i] != &g_label_generic) {
|
|
|
|
mediasize = pp->mediasize;
|
|
|
|
} else {
|
|
|
|
mediasize = pp->mediasize - pp->sectorsize;
|
|
|
|
}
|
|
|
|
g_label_create(NULL, mp, pp, label,
|
|
|
|
g_labels[i]->ld_dirprefix, mediasize);
|
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_access(cp, -1, 0, 0);
|
2004-08-09 11:14:25 +00:00
|
|
|
end:
|
|
|
|
g_detach(cp);
|
2020-10-18 16:24:08 +00:00
|
|
|
end2:
|
2004-08-09 11:14:25 +00:00
|
|
|
g_destroy_consumer(cp);
|
|
|
|
g_destroy_geom(gp);
|
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 (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_label_ctl_create(struct gctl_req *req, struct g_class *mp)
|
|
|
|
{
|
|
|
|
struct g_provider *pp;
|
|
|
|
const char *name;
|
|
|
|
int *nargs;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
|
|
|
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
|
|
|
|
if (nargs == NULL) {
|
|
|
|
gctl_error(req, "No '%s' argument", "nargs");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*nargs != 2) {
|
2010-12-01 19:24:07 +00:00
|
|
|
gctl_error(req, "Invalid number of arguments.");
|
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;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* arg1 is the name of provider.
|
|
|
|
*/
|
2020-07-22 02:15:21 +00:00
|
|
|
pp = gctl_get_provider(req, "arg1");
|
|
|
|
if (pp == NULL)
|
2006-02-01 12:06:01 +00:00
|
|
|
return;
|
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
|
|
|
/*
|
|
|
|
* arg0 is the label.
|
|
|
|
*/
|
2006-02-01 12:06:01 +00:00
|
|
|
name = gctl_get_asciiparam(req, "arg0");
|
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
|
|
|
if (name == NULL) {
|
|
|
|
gctl_error(req, "No 'arg%d' argument", 0);
|
|
|
|
return;
|
|
|
|
}
|
2020-07-26 00:44:59 +00:00
|
|
|
g_label_create(req, mp, pp, name, G_LABEL_DIRPREFIX, pp->mediasize);
|
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 const char *
|
|
|
|
g_label_skip_dir(const char *name)
|
|
|
|
{
|
|
|
|
u_int i;
|
|
|
|
|
2020-07-09 02:52:39 +00:00
|
|
|
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0)
|
|
|
|
name += strlen(_PATH_DEV);
|
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 = 0; g_labels[i] != NULL; i++) {
|
2020-07-26 00:44:59 +00:00
|
|
|
if (strncmp(name, g_labels[i]->ld_dirprefix,
|
|
|
|
strlen(g_labels[i]->ld_dirprefix)) == 0) {
|
|
|
|
name += strlen(g_labels[i]->ld_dirprefix);
|
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
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct g_geom *
|
|
|
|
g_label_find_geom(struct g_class *mp, const char *name)
|
|
|
|
{
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_provider *pp;
|
|
|
|
const char *pname;
|
|
|
|
|
|
|
|
name = g_label_skip_dir(name);
|
|
|
|
LIST_FOREACH(gp, &mp->geom, geom) {
|
|
|
|
pp = LIST_FIRST(&gp->provider);
|
|
|
|
pname = g_label_skip_dir(pp->name);
|
|
|
|
if (strcmp(pname, name) == 0)
|
|
|
|
return (gp);
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_label_ctl_destroy(struct gctl_req *req, struct g_class *mp)
|
|
|
|
{
|
|
|
|
int *nargs, *force, error, i;
|
|
|
|
struct g_geom *gp;
|
|
|
|
const char *name;
|
|
|
|
char param[16];
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
|
|
|
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
|
|
|
|
if (nargs == NULL) {
|
|
|
|
gctl_error(req, "No '%s' argument", "nargs");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*nargs <= 0) {
|
|
|
|
gctl_error(req, "Missing device(s).");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
force = gctl_get_paraml(req, "force", sizeof(*force));
|
|
|
|
if (force == NULL) {
|
|
|
|
gctl_error(req, "No 'force' argument");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < *nargs; i++) {
|
|
|
|
snprintf(param, sizeof(param), "arg%d", i);
|
2006-02-01 12:06:01 +00:00
|
|
|
name = gctl_get_asciiparam(req, param);
|
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
|
|
|
if (name == NULL) {
|
|
|
|
gctl_error(req, "No 'arg%d' argument", i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gp = g_label_find_geom(mp, name);
|
|
|
|
if (gp == NULL) {
|
|
|
|
G_LABEL_DEBUG(1, "Label %s is invalid.", name);
|
|
|
|
gctl_error(req, "Label %s is invalid.", name);
|
2006-02-01 12:06:01 +00:00
|
|
|
return;
|
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
|
|
|
}
|
|
|
|
error = g_label_destroy(gp, *force);
|
|
|
|
if (error != 0) {
|
|
|
|
gctl_error(req, "Cannot destroy label %s (error=%d).",
|
|
|
|
LIST_FIRST(&gp->provider)->name, error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
g_label_config(struct gctl_req *req, struct g_class *mp, const char *verb)
|
|
|
|
{
|
|
|
|
uint32_t *version;
|
|
|
|
|
|
|
|
g_topology_assert();
|
|
|
|
|
|
|
|
version = gctl_get_paraml(req, "version", sizeof(*version));
|
|
|
|
if (version == NULL) {
|
|
|
|
gctl_error(req, "No '%s' argument.", "version");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*version != G_LABEL_VERSION) {
|
|
|
|
gctl_error(req, "Userland and kernel parts are out of sync.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(verb, "create") == 0) {
|
|
|
|
g_label_ctl_create(req, mp);
|
|
|
|
return;
|
2004-07-05 21:16:37 +00:00
|
|
|
} else if (strcmp(verb, "destroy") == 0 ||
|
|
|
|
strcmp(verb, "stop") == 0) {
|
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_label_ctl_destroy(req, mp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gctl_error(req, "Unknown verb.");
|
|
|
|
}
|
|
|
|
|
|
|
|
DECLARE_GEOM_CLASS(g_label_class, g_label);
|
2018-04-10 19:18:16 +00:00
|
|
|
MODULE_VERSION(geom_label, 0);
|