diff options
author | artem <none@none> | 2006-10-12 22:44:10 -0700 |
---|---|---|
committer | artem <none@none> | 2006-10-12 22:44:10 -0700 |
commit | 18c2aff776a775d34a4c9893a4c72e0434d68e36 (patch) | |
tree | 2ce07e824c6b4db04bfedb4dea79bc5f255851ed /usr/src/lib/libdiskmgt/common/slice.c | |
parent | 38787b9f841232f52e2f48dd8a9e475d09954391 (diff) | |
download | illumos-joyent-18c2aff776a775d34a4c9893a4c72e0434d68e36.tar.gz |
PSARC 2005/399 Tamarack: Removable Media Enhancements in Solaris
6460497 Tamarack (ON)
6460498 vold EOF removal
--HG--
rename : usr/src/cmd/fs.d/hsfs/ident/Makefile => deleted_files/usr/src/cmd/fs.d/hsfs/ident/Makefile
rename : usr/src/cmd/fs.d/hsfs/ident/ident_hsfs.c => deleted_files/usr/src/cmd/fs.d/hsfs/ident/ident_hsfs.c
rename : usr/src/cmd/fs.d/pcfs/ident/Makefile => deleted_files/usr/src/cmd/fs.d/pcfs/ident/Makefile
rename : usr/src/cmd/fs.d/pcfs/ident/ident_pcfs.c => deleted_files/usr/src/cmd/fs.d/pcfs/ident/ident_pcfs.c
rename : usr/src/cmd/fs.d/udfs/ident/Makefile => deleted_files/usr/src/cmd/fs.d/udfs/ident/Makefile
rename : usr/src/cmd/fs.d/udfs/ident/ident_udfs.c => deleted_files/usr/src/cmd/fs.d/udfs/ident/ident_udfs.c
rename : usr/src/cmd/fs.d/ufs/ident/Makefile => deleted_files/usr/src/cmd/fs.d/ufs/ident/Makefile
rename : usr/src/cmd/fs.d/ufs/ident/ident_ufs.c => deleted_files/usr/src/cmd/fs.d/ufs/ident/ident_ufs.c
rename : usr/src/cmd/initpkg/init.d/volmgt => deleted_files/usr/src/cmd/initpkg/init.d/volmgt
rename : usr/src/cmd/volmgt/Makefile => deleted_files/usr/src/cmd/volmgt/Makefile
rename : usr/src/cmd/volmgt/Makefile.volmgt => deleted_files/usr/src/cmd/volmgt/Makefile.volmgt
rename : usr/src/cmd/volmgt/etc/Makefile => deleted_files/usr/src/cmd/volmgt/etc/Makefile
rename : usr/src/cmd/volmgt/etc/rmmount.conf => deleted_files/usr/src/cmd/volmgt/etc/rmmount.conf
rename : usr/src/cmd/volmgt/etc/svc-volfs => deleted_files/usr/src/cmd/volmgt/etc/svc-volfs
rename : usr/src/cmd/volmgt/etc/vold.conf => deleted_files/usr/src/cmd/volmgt/etc/vold.conf
rename : usr/src/cmd/volmgt/etc/volfs.xml => deleted_files/usr/src/cmd/volmgt/etc/volfs.xml
rename : usr/src/cmd/volmgt/req.flg => deleted_files/usr/src/cmd/volmgt/req.flg
rename : usr/src/cmd/volmgt/rmm/Makefile => deleted_files/usr/src/cmd/volmgt/rmm/Makefile
rename : usr/src/cmd/volmgt/rmm/action_dvdvideo.c => deleted_files/usr/src/cmd/volmgt/rmm/action_dvdvideo.c
rename : usr/src/cmd/volmgt/rmm/action_filemgr.c => deleted_files/usr/src/cmd/volmgt/rmm/action_filemgr.c
rename : usr/src/cmd/volmgt/rmm/action_test.c => deleted_files/usr/src/cmd/volmgt/rmm/action_test.c
rename : usr/src/cmd/volmgt/rmm/action_wabi.c => deleted_files/usr/src/cmd/volmgt/rmm/action_wabi.c
rename : usr/src/cmd/volmgt/rmm/action_workman.c => deleted_files/usr/src/cmd/volmgt/rmm/action_workman.c
rename : usr/src/cmd/volmgt/rmm/action_xmcd.c => deleted_files/usr/src/cmd/volmgt/rmm/action_xmcd.c
rename : usr/src/cmd/volmgt/rmm/req.flg => deleted_files/usr/src/cmd/volmgt/rmm/req.flg
rename : usr/src/cmd/volmgt/rmm/rmm.c => deleted_files/usr/src/cmd/volmgt/rmm/rmm.c
rename : usr/src/cmd/volmgt/rmm/rmm_config.c => deleted_files/usr/src/cmd/volmgt/rmm/rmm_config.c
rename : usr/src/cmd/volmgt/rmm/rmm_int.h => deleted_files/usr/src/cmd/volmgt/rmm/rmm_int.h
rename : usr/src/cmd/volmgt/rmm/rmm_util.c => deleted_files/usr/src/cmd/volmgt/rmm/rmm_util.c
rename : usr/src/cmd/volmgt/test/Makefile => deleted_files/usr/src/cmd/volmgt/test/Makefile
rename : usr/src/cmd/volmgt/test/README => deleted_files/usr/src/cmd/volmgt/test/README
rename : usr/src/cmd/volmgt/test/devlink.vt => deleted_files/usr/src/cmd/volmgt/test/devlink.vt
rename : usr/src/cmd/volmgt/test/stress => deleted_files/usr/src/cmd/volmgt/test/stress
rename : usr/src/cmd/volmgt/test/test_class_list => deleted_files/usr/src/cmd/volmgt/test/test_class_list
rename : usr/src/cmd/volmgt/test/test_suite_list => deleted_files/usr/src/cmd/volmgt/test/test_suite_list
rename : usr/src/cmd/volmgt/test/test_utilities_list => deleted_files/usr/src/cmd/volmgt/test/test_utilities_list
rename : usr/src/cmd/volmgt/test/voltestdrv.c => deleted_files/usr/src/cmd/volmgt/test/voltestdrv.c
rename : usr/src/cmd/volmgt/test/voltestdrv.conf => deleted_files/usr/src/cmd/volmgt/test/voltestdrv.conf
rename : usr/src/cmd/volmgt/test/voltestdrv.h => deleted_files/usr/src/cmd/volmgt/test/voltestdrv.h
rename : usr/src/cmd/volmgt/test/vttest.c => deleted_files/usr/src/cmd/volmgt/test/vttest.c
rename : usr/src/cmd/volmgt/util/Makefile => deleted_files/usr/src/cmd/volmgt/util/Makefile
rename : usr/src/cmd/volmgt/util/volcancel.c => deleted_files/usr/src/cmd/volmgt/util/volcancel.c
rename : usr/src/cmd/volmgt/util/volck.c => deleted_files/usr/src/cmd/volmgt/util/volck.c
rename : usr/src/cmd/volmgt/util/volmissing.c => deleted_files/usr/src/cmd/volmgt/util/volmissing.c
rename : usr/src/cmd/volmgt/util/volrmmount.c => deleted_files/usr/src/cmd/volmgt/util/volrmmount.c
rename : usr/src/cmd/volmgt/util/volsetup => deleted_files/usr/src/cmd/volmgt/util/volsetup
rename : usr/src/cmd/volmgt/util/volstat.c => deleted_files/usr/src/cmd/volmgt/util/volstat.c
rename : usr/src/cmd/volmgt/util/volutil.h => deleted_files/usr/src/cmd/volmgt/util/volutil.h
rename : usr/src/cmd/volmgt/vold/Makefile => deleted_files/usr/src/cmd/volmgt/vold/Makefile
rename : usr/src/cmd/volmgt/vold/action.h => deleted_files/usr/src/cmd/volmgt/vold/action.h
rename : usr/src/cmd/volmgt/vold/blank_partition.c => deleted_files/usr/src/cmd/volmgt/vold/blank_partition.c
rename : usr/src/cmd/volmgt/vold/db.h => deleted_files/usr/src/cmd/volmgt/vold/db.h
rename : usr/src/cmd/volmgt/vold/db_mem.c => deleted_files/usr/src/cmd/volmgt/vold/db_mem.c
rename : usr/src/cmd/volmgt/vold/db_nis.c => deleted_files/usr/src/cmd/volmgt/vold/db_nis.c
rename : usr/src/cmd/volmgt/vold/db_nis.h => deleted_files/usr/src/cmd/volmgt/vold/db_nis.h
rename : usr/src/cmd/volmgt/vold/dev.h => deleted_files/usr/src/cmd/volmgt/vold/dev.h
rename : usr/src/cmd/volmgt/vold/dev_cdrom.c => deleted_files/usr/src/cmd/volmgt/vold/dev_cdrom.c
rename : usr/src/cmd/volmgt/vold/dev_cdtest.c => deleted_files/usr/src/cmd/volmgt/vold/dev_cdtest.c
rename : usr/src/cmd/volmgt/vold/dev_floppy.c => deleted_files/usr/src/cmd/volmgt/vold/dev_floppy.c
rename : usr/src/cmd/volmgt/vold/dev_pcmem.c => deleted_files/usr/src/cmd/volmgt/vold/dev_pcmem.c
rename : usr/src/cmd/volmgt/vold/dev_rmdisk.c => deleted_files/usr/src/cmd/volmgt/vold/dev_rmdisk.c
rename : usr/src/cmd/volmgt/vold/dev_rmscsi.c => deleted_files/usr/src/cmd/volmgt/vold/dev_rmscsi.c
rename : usr/src/cmd/volmgt/vold/dev_test.c => deleted_files/usr/src/cmd/volmgt/vold/dev_test.c
rename : usr/src/cmd/volmgt/vold/fdisk_partition.c => deleted_files/usr/src/cmd/volmgt/vold/fdisk_partition.c
rename : usr/src/cmd/volmgt/vold/hsfs_partition.c => deleted_files/usr/src/cmd/volmgt/vold/hsfs_partition.c
rename : usr/src/cmd/volmgt/vold/label.h => deleted_files/usr/src/cmd/volmgt/vold/label.h
rename : usr/src/cmd/volmgt/vold/label_cdrom.c => deleted_files/usr/src/cmd/volmgt/vold/label_cdrom.c
rename : usr/src/cmd/volmgt/vold/label_dos.c => deleted_files/usr/src/cmd/volmgt/vold/label_dos.c
rename : usr/src/cmd/volmgt/vold/label_sun.c => deleted_files/usr/src/cmd/volmgt/vold/label_sun.c
rename : usr/src/cmd/volmgt/vold/label_test.c => deleted_files/usr/src/cmd/volmgt/vold/label_test.c
rename : usr/src/cmd/volmgt/vold/medium.c => deleted_files/usr/src/cmd/volmgt/vold/medium.c
rename : usr/src/cmd/volmgt/vold/medium.h => deleted_files/usr/src/cmd/volmgt/vold/medium.h
rename : usr/src/cmd/volmgt/vold/medium_private.h => deleted_files/usr/src/cmd/volmgt/vold/medium_private.h
rename : usr/src/cmd/volmgt/vold/name_factory.c => deleted_files/usr/src/cmd/volmgt/vold/name_factory.c
rename : usr/src/cmd/volmgt/vold/name_factory.h => deleted_files/usr/src/cmd/volmgt/vold/name_factory.h
rename : usr/src/cmd/volmgt/vold/nfs_server.c => deleted_files/usr/src/cmd/volmgt/vold/nfs_server.c
rename : usr/src/cmd/volmgt/vold/nfs_trace.c => deleted_files/usr/src/cmd/volmgt/vold/nfs_trace.c
rename : usr/src/cmd/volmgt/vold/node.h => deleted_files/usr/src/cmd/volmgt/vold/node.h
rename : usr/src/cmd/volmgt/vold/obj.h => deleted_files/usr/src/cmd/volmgt/vold/obj.h
rename : usr/src/cmd/volmgt/vold/partition.c => deleted_files/usr/src/cmd/volmgt/vold/partition.c
rename : usr/src/cmd/volmgt/vold/partition.h => deleted_files/usr/src/cmd/volmgt/vold/partition.h
rename : usr/src/cmd/volmgt/vold/partition_private.h => deleted_files/usr/src/cmd/volmgt/vold/partition_private.h
rename : usr/src/cmd/volmgt/vold/pcfs_partition.c => deleted_files/usr/src/cmd/volmgt/vold/pcfs_partition.c
rename : usr/src/cmd/volmgt/vold/solaris_partition.c => deleted_files/usr/src/cmd/volmgt/vold/solaris_partition.c
rename : usr/src/cmd/volmgt/vold/udfs_partition.c => deleted_files/usr/src/cmd/volmgt/vold/udfs_partition.c
rename : usr/src/cmd/volmgt/vold/ufs_partition.c => deleted_files/usr/src/cmd/volmgt/vold/ufs_partition.c
rename : usr/src/cmd/volmgt/vold/util.h => deleted_files/usr/src/cmd/volmgt/vold/util.h
rename : usr/src/cmd/volmgt/vold/vold.h => deleted_files/usr/src/cmd/volmgt/vold/vold.h
rename : usr/src/cmd/volmgt/vold/vold_action.c => deleted_files/usr/src/cmd/volmgt/vold/vold_action.c
rename : usr/src/cmd/volmgt/vold/vold_config.c => deleted_files/usr/src/cmd/volmgt/vold/vold_config.c
rename : usr/src/cmd/volmgt/vold/vold_db.c => deleted_files/usr/src/cmd/volmgt/vold/vold_db.c
rename : usr/src/cmd/volmgt/vold/vold_dev.c => deleted_files/usr/src/cmd/volmgt/vold/vold_dev.c
rename : usr/src/cmd/volmgt/vold/vold_err.c => deleted_files/usr/src/cmd/volmgt/vold/vold_err.c
rename : usr/src/cmd/volmgt/vold/vold_label.c => deleted_files/usr/src/cmd/volmgt/vold/vold_label.c
rename : usr/src/cmd/volmgt/vold/vold_main.c => deleted_files/usr/src/cmd/volmgt/vold/vold_main.c
rename : usr/src/cmd/volmgt/vold/vold_mnt.c => deleted_files/usr/src/cmd/volmgt/vold/vold_mnt.c
rename : usr/src/cmd/volmgt/vold/vold_node.c => deleted_files/usr/src/cmd/volmgt/vold/vold_node.c
rename : usr/src/cmd/volmgt/vold/vold_obj.c => deleted_files/usr/src/cmd/volmgt/vold/vold_obj.c
rename : usr/src/cmd/volmgt/vold/vold_path.c => deleted_files/usr/src/cmd/volmgt/vold/vold_path.c
rename : usr/src/cmd/volmgt/vold/vold_proc.c => deleted_files/usr/src/cmd/volmgt/vold/vold_proc.c
rename : usr/src/cmd/volmgt/vold/vold_props.c => deleted_files/usr/src/cmd/volmgt/vold/vold_props.c
rename : usr/src/cmd/volmgt/vold/vold_sysevent.c => deleted_files/usr/src/cmd/volmgt/vold/vold_sysevent.c
rename : usr/src/cmd/volmgt/vold/vold_util.c => deleted_files/usr/src/cmd/volmgt/vold/vold_util.c
rename : usr/src/cmd/volmgt/vold/vold_vol.c => deleted_files/usr/src/cmd/volmgt/vold/vold_vol.c
rename : usr/src/cmd/volmgt/vold/vtoc.c => deleted_files/usr/src/cmd/volmgt/vold/vtoc.c
rename : usr/src/cmd/volmgt/vold/vtoc.h => deleted_files/usr/src/cmd/volmgt/vold/vtoc.h
rename : usr/src/head/rmmount.h => deleted_files/usr/src/head/rmmount.h
rename : usr/src/lib/libvolmgt/common/volattr.c => deleted_files/usr/src/lib/libvolmgt/common/volattr.c
rename : usr/src/lib/libvolmgt/common/volmgt_fsi.c => deleted_files/usr/src/lib/libvolmgt/common/volmgt_fsi.c
rename : usr/src/lib/libvolmgt/common/volmgt_fsi_private.h => deleted_files/usr/src/lib/libvolmgt/common/volmgt_fsi_private.h
rename : usr/src/lib/libvolmgt/common/volmgt_fsidbi.c => deleted_files/usr/src/lib/libvolmgt/common/volmgt_fsidbi.c
rename : usr/src/lib/libvolmgt/common/volname.c => deleted_files/usr/src/lib/libvolmgt/common/volname.c
rename : usr/src/lib/libvolmgt/common/volutil.c => deleted_files/usr/src/lib/libvolmgt/common/volutil.c
rename : usr/src/pkgdefs/SUNWpcmem/preinstall => deleted_files/usr/src/pkgdefs/SUNWpcmem/preinstall
rename : usr/src/pkgdefs/SUNWvolr/Makefile => deleted_files/usr/src/pkgdefs/SUNWvolr/Makefile
rename : usr/src/pkgdefs/SUNWvolr/pkginfo.tmpl => deleted_files/usr/src/pkgdefs/SUNWvolr/pkginfo.tmpl
rename : usr/src/pkgdefs/SUNWvolr/postinstall => deleted_files/usr/src/pkgdefs/SUNWvolr/postinstall
rename : usr/src/pkgdefs/SUNWvolr/preinstall => deleted_files/usr/src/pkgdefs/SUNWvolr/preinstall
rename : usr/src/pkgdefs/SUNWvolr/prototype_com => deleted_files/usr/src/pkgdefs/SUNWvolr/prototype_com
rename : usr/src/pkgdefs/SUNWvolr/prototype_i386 => deleted_files/usr/src/pkgdefs/SUNWvolr/prototype_i386
rename : usr/src/pkgdefs/SUNWvolr/prototype_sparc => deleted_files/usr/src/pkgdefs/SUNWvolr/prototype_sparc
rename : usr/src/pkgdefs/SUNWvolu/Makefile => deleted_files/usr/src/pkgdefs/SUNWvolu/Makefile
rename : usr/src/pkgdefs/SUNWvolu/depend => deleted_files/usr/src/pkgdefs/SUNWvolu/depend
rename : usr/src/pkgdefs/SUNWvolu/pkginfo.tmpl => deleted_files/usr/src/pkgdefs/SUNWvolu/pkginfo.tmpl
rename : usr/src/pkgdefs/SUNWvolu/postremove => deleted_files/usr/src/pkgdefs/SUNWvolu/postremove
rename : usr/src/pkgdefs/SUNWvolu/prototype_com => deleted_files/usr/src/pkgdefs/SUNWvolu/prototype_com
rename : usr/src/pkgdefs/SUNWvolu/prototype_i386 => deleted_files/usr/src/pkgdefs/SUNWvolu/prototype_i386
rename : usr/src/pkgdefs/SUNWvolu/prototype_sparc => deleted_files/usr/src/pkgdefs/SUNWvolu/prototype_sparc
rename : usr/src/pkgdefs/common_files/i.rmmconf => deleted_files/usr/src/pkgdefs/common_files/i.rmmconf
rename : usr/src/pkgdefs/common_files/i.voldconf => deleted_files/usr/src/pkgdefs/common_files/i.voldconf
rename : usr/src/uts/common/io/vol.c => deleted_files/usr/src/uts/common/io/vol.c
rename : usr/src/uts/common/io/vol.conf => deleted_files/usr/src/uts/common/io/vol.conf
rename : usr/src/uts/common/sys/vol.h => deleted_files/usr/src/uts/common/sys/vol.h
rename : usr/src/uts/intel/vol/Makefile => deleted_files/usr/src/uts/intel/vol/Makefile
rename : usr/src/uts/sparc/vol/Makefile => deleted_files/usr/src/uts/sparc/vol/Makefile
rename : usr/src/cmd/volmgt/util/eject.c => usr/src/cmd/eject/eject.c
rename : usr/src/cmd/volmgt/util/volcheck.c => usr/src/cmd/volcheck/volcheck.c
Diffstat (limited to 'usr/src/lib/libdiskmgt/common/slice.c')
-rw-r--r-- | usr/src/lib/libdiskmgt/common/slice.c | 493 |
1 files changed, 14 insertions, 479 deletions
diff --git a/usr/src/lib/libdiskmgt/common/slice.c b/usr/src/lib/libdiskmgt/common/slice.c index e94c443cfb..2e76e43671 100644 --- a/usr/src/lib/libdiskmgt/common/slice.c +++ b/usr/src/lib/libdiskmgt/common/slice.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -73,17 +72,9 @@ static int desc_ok(descriptor_t *dp); static void dsk2rdsk(char *dsk, char *rdsk, int size); static int get_attrs(descriptor_t *dp, int fd, nvlist_t *attrs); static descriptor_t **get_fixed_assocs(descriptor_t *desc, int *errp); -static descriptor_t **get_removable_assocs(descriptor_t *desc, char *volm_path, - int *errp); static int get_slice_num(slice_t *devp); static int match_fixed_name(disk_t *dp, char *name, int *errp); -static int match_removable_name(disk_t *dp, char *name, int *errp); static int make_fixed_descriptors(disk_t *dp); -static int make_removable_descriptors(disk_t *dp); -static int make_volm_dir_descriptors(disk_t *dp, int fd, - char *volm_path); -static int num_removable_slices(int fd, struct stat *bufp, - char *volm_path); descriptor_t ** slice_get_assoc_descriptors(descriptor_t *desc, dm_desc_type_t type, @@ -114,35 +105,13 @@ slice_get_assoc_descriptors(descriptor_t *desc, dm_desc_type_t type, descriptor_t ** slice_get_assocs(descriptor_t *desc, int *errp) { - int under_volm = 0; - char volm_path[MAXPATHLEN]; - /* Just check the first drive name. */ if (desc->p.disk->aliases == NULL) { *errp = 0; return (libdiskmgt_empty_desc_array(errp)); } - if (desc->p.disk->removable) { - if ((under_volm = media_get_volm_path(desc->p.disk, volm_path, - sizeof (volm_path)))) { - if (volm_path[0] == 0) { - /* no media */ - *errp = 0; - return (libdiskmgt_empty_desc_array(errp)); - } - } - } - - if (desc->p.disk->removable) { - if (under_volm) { - return (get_removable_assocs(desc, volm_path, errp)); - } else { - return (get_fixed_assocs(desc, errp)); - } - } else { - return (get_fixed_assocs(desc, errp)); - } + return (get_fixed_assocs(desc, errp)); } nvlist_t * @@ -188,24 +157,21 @@ slice_get_descriptor_by_name(char *name, int *errp) disk_t *dp; for (dp = cache_get_disklist(); dp != NULL; dp = dp->next) { - if (dp->removable) { - found = match_removable_name(dp, name, errp); - } else { found = match_fixed_name(dp, name, errp); - } - if (found) { - char mname[MAXPATHLEN]; + if (found) { + char mname[MAXPATHLEN]; - if (*errp != 0) { - return (NULL); - } + if (*errp != 0) { + return (NULL); + } - mname[0] = 0; - (void) media_read_name(dp, mname, sizeof (mname)); + mname[0] = 0; + (void) media_read_name(dp, mname, sizeof (mname)); - return (cache_get_desc(DM_SLICE, dp, name, mname, errp)); - } + return (cache_get_desc(DM_SLICE, dp, name, mname, + errp)); + } } *errp = ENODEV; @@ -310,11 +276,7 @@ slice_make_descriptors() while (dp != NULL) { int error; - if (dp->removable) { - error = make_removable_descriptors(dp); - } else { - error = make_fixed_descriptors(dp); - } + error = make_fixed_descriptors(dp); if (error != 0) { return (error); } @@ -750,140 +712,6 @@ get_fixed_assocs(descriptor_t *desc, int *errp) return (slices); } -/* - * Called for loaded removable media under volume management control. - */ -static descriptor_t ** -get_removable_assocs(descriptor_t *desc, char *volm_path, int *errp) -{ - int pos; - int fd; - int cnt; - struct stat buf; - descriptor_t **slices; - char *media_name = NULL; - char devpath[MAXPATHLEN]; - - /* get the media name from the descriptor */ - if (desc->type == DM_MEDIA) { - media_name = desc->name; - } else { - /* must be a DM_PARTITION */ - media_name = desc->secondary_name; - } - - /* - * For removable media under volm control the volm_path will - * either be a device (if the media is made up of a single slice) or - * a directory (if the media has multiple slices) with the slices - * as devices contained in the directory. - */ - - if ((fd = open(volm_path, O_RDONLY|O_NDELAY)) < 0 || - fstat(fd, &buf) != 0) { - *errp = ENODEV; - return (NULL); - } - - cnt = num_removable_slices(fd, &buf, volm_path); - - /* allocate the array for the descriptors */ - slices = calloc(cnt + 1, sizeof (descriptor_t *)); - if (slices == NULL) { - *errp = ENOMEM; - return (NULL); - } - - slice_rdsk2dsk(volm_path, devpath, sizeof (devpath)); - - pos = 0; - *errp = 0; - if (S_ISCHR(buf.st_mode)) { - struct dk_minfo minfo; - - /* Make sure media has readable label */ - if (media_read_info(fd, &minfo)) { - int status; - int data_format = FMT_UNKNOWN; - struct vtoc vtoc; - struct dk_gpt *efip; - - if ((status = read_vtoc(fd, &vtoc)) >= 0) { - data_format = FMT_VTOC; - } else if (status == VT_ENOTSUP && - efi_alloc_and_read(fd, &efip) >= 0) { - data_format = FMT_EFI; - } - - if (data_format != FMT_UNKNOWN) { - /* has a readable label */ - slices[pos++] = - cache_get_desc(DM_SLICE, desc->p.disk, - devpath, media_name, errp); - } - } - (void) close(fd); - } else if (S_ISDIR(buf.st_mode)) { - DIR *dirp; - struct dirent *dentp; - - /* rewind, num_removable_slices already traversed */ - (void) lseek(fd, 0, SEEK_SET); - - if ((dirp = fdopendir(fd)) == NULL) { - *errp = errno; - (void) close(fd); - return (NULL); - } - - while ((dentp = readdir(dirp)) != NULL) { - int dfd; - int is_dev = 0; - char slice_path[MAXPATHLEN]; - - if (libdiskmgt_str_eq(".", dentp->d_name) || - libdiskmgt_str_eq("..", dentp->d_name)) { - continue; - } - - (void) snprintf(slice_path, sizeof (slice_path), - "%s/%s", devpath, dentp->d_name); - - if ((dfd = open(slice_path, O_RDONLY|O_NDELAY)) >= 0) { - struct stat buf; - - if (fstat(dfd, &buf) == 0 && - S_ISCHR(buf.st_mode)) { - is_dev = 1; - } - (void) close(dfd); - } - - if (!is_dev) { - continue; - } - - slices[pos++] = cache_get_desc(DM_SLICE, desc->p.disk, - slice_path, media_name, errp); - if (*errp != 0) { - break; - } - } - (void) closedir(dirp); - } else { - (void) close(fd); - } - - slices[pos] = NULL; - - if (*errp != 0) { - cache_free_descriptors(slices); - return (NULL); - } - - return (slices); -} - static int get_slice_num(slice_t *devp) { @@ -979,141 +807,6 @@ make_fixed_descriptors(disk_t *dp) } /* - * For removable media under volm control we have to do some special handling. - * We don't use the vtoc and /dev/dsk devpaths, since the slices are named - * under the /vol fs. - */ -static int -make_removable_descriptors(disk_t *dp) -{ - char volm_path[MAXPATHLEN]; - int error; - int fd; - - /* - * If this removable drive is not under volm control, just use - * normal handling. - */ - if (!media_get_volm_path(dp, volm_path, sizeof (volm_path))) { - return (make_fixed_descriptors(dp)); - } - - if (volm_path[0] == 0) { - /* no media */ - return (0); - } - - /* - * For removable media under volm control the rmmedia_devapth will - * either be a device (if the media is made up of a single slice) or - * a directory (if the media has multiple slices) with the slices - * as devices contained in the directory. - */ - error = 0; - if ((fd = open(volm_path, O_RDONLY|O_NDELAY)) >= 0) { - struct stat buf; - - if (fstat(fd, &buf) == 0) { - if (S_ISCHR(buf.st_mode)) { - int status; - int data_format = FMT_UNKNOWN; - struct dk_minfo minfo; - int error; - struct vtoc vtoc; - struct dk_gpt *efip; - char devpath[MAXPATHLEN]; - - /* Make sure media has readable label */ - if (!media_read_info(fd, &minfo)) { - /* no media */ - return (0); - } - - if ((status = read_vtoc(fd, &vtoc)) >= 0) { - data_format = FMT_VTOC; - } else if (status == VT_ENOTSUP && - efi_alloc_and_read(fd, &efip) >= 0) { - data_format = FMT_EFI; - } - - if (data_format == FMT_UNKNOWN) { - /* no readable label */ - return (0); - } - - slice_rdsk2dsk(volm_path, devpath, sizeof (devpath)); - /* The media name is the volm_path in this case. */ - cache_load_desc(DM_SLICE, dp, devpath, volm_path, &error); - - } else if (S_ISDIR(buf.st_mode)) { - /* each device file in the dir represents a slice */ - error = make_volm_dir_descriptors(dp, fd, volm_path); - } - } - (void) close(fd); - } - - return (error); -} - -/* - * This handles removable media with slices under volume management control. - * In this case we have a dir which is the media name and each slice on the - * media is a device file in this dir. - */ -static int -make_volm_dir_descriptors(disk_t *dp, int dirfd, char *volm_path) -{ - int error; - DIR *dirp; - struct dirent *dentp; - char devpath[MAXPATHLEN]; - - dirfd = dup(dirfd); - if (dirfd < 0) - return (0); - if ((dirp = fdopendir(dirfd)) == NULL) { - (void) close(dirfd); - return (0); - } - - slice_rdsk2dsk(volm_path, devpath, sizeof (devpath)); - - error = 0; - while ((dentp = readdir(dirp)) != NULL) { - int fd; - char slice_path[MAXPATHLEN]; - - if (libdiskmgt_str_eq(".", dentp->d_name) || - libdiskmgt_str_eq("..", dentp->d_name)) { - continue; - } - - (void) snprintf(slice_path, sizeof (slice_path), "%s/%s", - devpath, dentp->d_name); - - if ((fd = open(slice_path, O_RDONLY|O_NDELAY)) >= 0) { - struct stat buf; - - /* The media name is the volm_path in this case. */ - if (fstat(fd, &buf) == 0 && S_ISCHR(buf.st_mode)) { - cache_load_desc(DM_SLICE, dp, slice_path, - volm_path, &error); - if (error != 0) { - (void) close(fd); - break; - } - } - - (void) close(fd); - } - } - (void) closedir(dirp); - - return (error); -} - -/* * Just look for the name on the devpaths we have cached. Return 1 if we * find the name and the size of that slice is non-zero. */ @@ -1206,161 +899,3 @@ match_fixed_name(disk_t *diskp, char *name, int *errp) *errp = ENODEV; return (1); } - -static int -match_removable_name(disk_t *diskp, char *name, int *errp) -{ - char volm_path[MAXPATHLEN]; - int found; - int fd; - struct stat buf; - - /* - * If this removable drive is not under volm control, just use - * normal handling. - */ - if (!media_get_volm_path(diskp, volm_path, sizeof (volm_path))) { - return (match_fixed_name(diskp, name, errp)); - } - - if (volm_path[0] == 0) { - /* no media */ - *errp = 0; - return (0); - } - - /* - * For removable media under volm control the rmmedia_devapth will - * either be a device (if the media is made up of a single slice) or - * a directory (if the media has multiple slices) with the slices - * as devices contained in the directory. - */ - - *errp = 0; - - if ((fd = open(volm_path, O_RDONLY|O_NDELAY)) == -1 || - fstat(fd, &buf) != 0) { - return (0); - } - - found = 0; - - if (S_ISCHR(buf.st_mode)) { - char devpath[MAXPATHLEN]; - - slice_rdsk2dsk(volm_path, devpath, sizeof (devpath)); - if (libdiskmgt_str_eq(name, devpath)) { - found = 1; - } - (void) close(fd); - return (found); - } else if (S_ISDIR(buf.st_mode)) { - /* each device file in the dir represents a slice */ - DIR *dirp; - struct dirent *dentp; - char devpath[MAXPATHLEN]; - - if ((dirp = fdopendir(fd)) == NULL) { - (void) close(fd); - return (0); - } - - slice_rdsk2dsk(volm_path, devpath, sizeof (devpath)); - - while ((dentp = readdir(dirp)) != NULL) { - char slice_path[MAXPATHLEN]; - - if (libdiskmgt_str_eq(".", dentp->d_name) || - libdiskmgt_str_eq("..", dentp->d_name)) { - continue; - } - - (void) snprintf(slice_path, sizeof (slice_path), - "%s/%s", devpath, dentp->d_name); - - if (libdiskmgt_str_eq(name, slice_path)) { - /* found name, check device */ - int dfd; - int is_dev = 0; - - dfd = open(slice_path, O_RDONLY|O_NDELAY); - if (dfd >= 0) { - struct stat buf; - - if (fstat(dfd, &buf) == 0 && - S_ISCHR(buf.st_mode)) { - is_dev = 1; - } - (void) close(dfd); - } - - /* we found the name */ - found = 1; - - if (!is_dev) { - *errp = ENODEV; - } - - break; - } - } - (void) closedir(dirp); - } else { - (void) close(fd); - } - - return (found); -} - -static int -num_removable_slices(int fd, struct stat *bufp, char *volm_path) -{ - int cnt = 0; - - if (S_ISCHR(bufp->st_mode)) - return (1); - - if (S_ISDIR(bufp->st_mode)) { - /* each device file in the dir represents a slice */ - DIR *dirp; - struct dirent *dentp; - char devpath[MAXPATHLEN]; - - fd = dup(fd); - - if (fd < 0) - return (0); - - if ((dirp = fdopendir(fd)) == NULL) { - (void) close(fd); - return (0); - } - - slice_rdsk2dsk(volm_path, devpath, sizeof (devpath)); - - while ((dentp = readdir(dirp)) != NULL) { - int dfd; - char slice_path[MAXPATHLEN]; - - if (libdiskmgt_str_eq(".", dentp->d_name) || - libdiskmgt_str_eq("..", dentp->d_name)) { - continue; - } - - (void) snprintf(slice_path, sizeof (slice_path), - "%s/%s", devpath, dentp->d_name); - - if ((dfd = open(slice_path, O_RDONLY|O_NDELAY)) >= 0) { - struct stat buf; - - if (fstat(dfd, &buf) == 0 && - S_ISCHR(buf.st_mode)) { - cnt++; - } - (void) close(dfd); - } - } - (void) closedir(dirp); - } - return (cnt); -} |