/***************************************************************************
*
* probe-volume.c : probe volumes
*
*
* Licensed under the Academic Free License version 2.1
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>
#include <libnvpair.h>
#include <libfstyp.h>
#include <sys/efi_partition.h>
#include <priv.h>
#include <sys/u8_textprep.h>
#include <libhal.h>
#include <cdutils.h>
#include <fsutils.h>
#include <logger.h>
static void
{
if (dbus_error_is_set(error)) {
}
}
/*
* Return a copy of a string without trailing spaces. If 'len' is non-zero,
* it specifies max length, otherwise the string must be null-terminated.
*/
static char *
{
char *dst, *p;
if (len == 0) {
}
*p-- = '\0';
}
}
return (dst);
}
static void
{
int err;
dbus_error_init (&error);
return;
}
/* label */
if (label_orig != NULL) {
}
/* Check if label is utf8 format */
} else {
}
/* uuid */
} else {
}
}
/*
*/
static void
{
uchar_t *p;
char *name;
int name_len;
int ipe_len;
/*
* find 1st Primary Volume Descriptor
*/
return;
}
return;
}
return;
}
}
/*
*/
#if defined(_LITTLE_ENDIAN)
#else
#endif
/*
* Look through path table entries
*/
return;
}
dbus_error_init (&error);
/* load sectors on demand */
break;
}
}
name_len = IPE_NAME_LEN(p);
/* only interested in root directories */
if (IPE_PARENT_NO (p) != 1) {
continue;
}
continue;
}
}
}
}
static dbus_bool_t
{
int profile;
int i;
dbus_error_init (&error);
} else {
}
switch (profile) {
case 0x08: /* CD-ROM */
disc_type = "cd_rom";
break;
case 0x09: /* CD-R */
disc_type = "cd_r";
break;
case 0x0A: /* CD-RW */
disc_type = "cd_rw";
break;
case 0x10: /* DVD-ROM */
disc_type = "dvd_rom";
break;
case 0x11: /* DVD-R Sequential */
disc_type = "dvd_r";
break;
case 0x12: /* DVD-RAM */
disc_type = "dvd_ram";
break;
case 0x13: /* DVD-RW Restricted Overwrite */
disc_type = "dvd_rw";
break;
case 0x14: /* DVD-RW Sequential */
disc_type = "dvd_rw";
break;
case 0x1A: /* DVD+RW */
disc_type = "dvd_plus_rw";
break;
case 0x1B: /* DVD+R */
disc_type = "dvd_plus_r";
break;
case 0x2B: /* DVD+R Double Layer */
disc_type = "dvd_plus_r_dl";
break;
case 0x40: /* BD-ROM */
disc_type = "bd_rom";
break;
case 0x41: /* BD-R Sequential */
disc_type = "bd_r";
break;
case 0x42: /* BD-R Random */
disc_type = "bd_r";
break;
case 0x43: /* BD-RE */
disc_type = "bd_re";
break;
case 0x50: /* HD DVD-ROM */
disc_type = "hddvd_rom";
break;
case 0x51: /* HD DVD-R */
disc_type = "hddvd_r";
break;
case 0x52: /* HD DVD-Rewritable */
disc_type = "hddvd_rw";
break;
}
}
if (!is_blank) {
/*
* XXX for some reason CDROMREADTOCENTRY fails on video DVDs,
* but extracting the toc directly works okay. And the toc
* data buffer length passed to read_toc() should be the same
* as the real buffer size.
*/
HAL_DEBUG(("read_toc failed"));
} else {
HAL_DEBUG (("read_toc again failed"));
} else {
/* skip leadout */
if (p[2] == 0xAA) {
continue;
}
if (p[1] & 4) {
} else {
}
}
}
}
}
return (FALSE);
}
out:
return (TRUE);
}
static void
{
/*
* Start with the 'basic' privilege set and then remove any
* of the 'basic' privileges that will not be needed.
*/
return;
}
/* Clear privileges we will not need from the 'basic' set */
/* for uscsi */
/* to open logindevperm'd devices */
/* Set the permitted privilege set. */
return;
}
/* Clear the limit set. */
return;
}
return;
}
}
int
{
int ret;
char *udi;
int dos_num;
char *parent_udi;
char *storage_device;
char *is_disc_str;
unsigned int block_size;
int partition_number = 0;
int i, dos_cnt;
int num_volumes;
char **volumes;
const char *fstype;
ret = 1;
goto out;
}
goto out;
}
goto out;
}
}
}
goto out;
}
goto out;
}
} else {
}
drop_privileges ();
setup_logger ();
dbus_error_init (&error);
goto out;
if (fd < 0) {
goto out;
}
if (rfd < 0) {
goto out;
}
/* block size and total size */
/* driver supports ioctl, but media is not available */
goto out;
} else {
/* driver does not support ioctl, e.g. lofi */
block_size = 512;
vol_size = 0;
}
if (is_disc) {
HAL_DEBUG (("probe_disc failed, skipping fstyp"));
goto out;
}
/* with audio present, create volume even if fs probing fails */
if (has_audio) {
ret = 0;
}
}
if (!has_data) {
goto skip_fs;
}
/*
* first get partitioning info
*/
if (is_dos) {
/* for a dos drive find partition offset */
goto out;
}
partition_scheme = "mbr";
} else {
if (!vtoc_one_slice_entire_disk(&vtoc)) {
partition_scheme = "smi";
HAL_DEBUG (("zero size partition"));
}
}
}
partition_scheme = "gpt";
HAL_DEBUG (("zero size partition"));
}
}
}
probe_offset = 0;
}
if (partition_scheme != NULL) {
} else {
}
/*
* ignore duplicate partitions
*/
for (i = 0; i < num_volumes; i++) {
continue; /* skip self */
}
if (dbus_error_is_set(&error)) {
continue;
}
if (v_start == partition_start) {
HAL_DEBUG (("duplicate partition"));
goto out;
}
}
}
/*
* now determine fs type
*
* XXX We could get better performance from block device,
* but for now we use raw device because:
*
* - fstyp_udfs has a bug that it only works on raw
*
* - sd has a bug that causes extremely slow reads
*/
HAL_DEBUG (("fstyp_init failed"));
goto out;
}
HAL_DEBUG (("fstyp ident or get_attr failed"));
goto out;
}
}
ret = 0;
out:
if (fd >= 0)
if (rfd >= 0)
}
return ret;
}