summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Shadura <andrewsh@debian.org>2016-04-26 23:15:12 +0200
committerAndrew Shadura <andrewsh@debian.org>2016-07-28 23:21:27 +0200
commita42f69bd23d0e64b3bfc81e9182c6fdbc5e7ab34 (patch)
treecbeaa30bd692c68b95ef8301df37ca177fe711b2
parent9178a1bcd66b04269831fac717ae383a22e2dd63 (diff)
Imported Upstream version 0.8.5
-rw-r--r--Makefile.in7
-rw-r--r--cd_disect.c11
-rw-r--r--config.h2
-rw-r--r--config.h.in2
-rwxr-xr-xconfigure20
-rw-r--r--configure.ac4
-rw-r--r--defs.h4
-rw-r--r--ecma167-udf.h10
-rw-r--r--mmc_format.c7
-rw-r--r--newfs_udf.c3
-rw-r--r--udf.c38
-rw-r--r--udf_allocentries.c7
-rw-r--r--udf_bmap.c9
-rw-r--r--udf_discop.c10
-rw-r--r--udf_readwrite.c14
-rw-r--r--udf_unix.c11
-rw-r--r--udf_verbose.c22
-rw-r--r--udfclient.c21
-rw-r--r--udfdump.c6
-rw-r--r--uscsi_subr.c.async608
-rw-r--r--vfs_dirhash.c4
21 files changed, 104 insertions, 716 deletions
diff --git a/Makefile.in b/Makefile.in
index f29bf74..c2795f5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -4,7 +4,7 @@
# Copyright 2003,2004,2005 Reinoud P.Zandijk
#
#
-# File $Id: Makefile.in,v 1.20 2009/07/24 16:51:49 reinoud Exp $ $Name: $
+# File $Id: Makefile.in,v 1.23 2016/04/26 19:29:29 reinoud Exp $ $Name: $
#
srcdir= @srcdir@
@@ -56,9 +56,10 @@ CFLAGS+= -DNEEDS_ISPRINT $(CPPFLAGS)
all: @BUILD_APPS@
install: @BUILD_APPS@
+ $(INSTALL) -d $(DESTDIR)/$(bindir)
for app in $(APPS) $(SCSI_APPS); do \
- echo "$(INSTALL) $$app $(bindir)/$$app"; \
- $(INSTALL) $$app $(bindir)/$$app; \
+ echo "$(INSTALL) $$app $(DESTDIR)/$(bindir)/$$app"; \
+ $(INSTALL) $$app $(DESTDIR)/$(bindir)/$$app; \
done
depend:
diff --git a/cd_disect.c b/cd_disect.c
index b79002f..a5e6bd7 100644
--- a/cd_disect.c
+++ b/cd_disect.c
@@ -2,7 +2,7 @@
/*
* File "cd_disect.c" is part of the UDFclient toolkit.
- * File $Id: cd_disect.c,v 1.79 2015/08/05 18:26:28 reinoud Exp $ $Name: $
+ * File $Id: cd_disect.c,v 1.80 2016/04/25 20:55:30 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -1036,6 +1036,7 @@ void dump_disc_information(void) {
if (nwa_valid) printf("\t\tNext writable : %d\n", next_writable_addr);
if (lra_valid) printf("\t\tLast recorded : %d\n", last_recorded_addr);
if (is_copy) printf("\t\tTrack is a copy\n");
+ if (is_damage) printf("\t\tTrack is damaged\n");
if (is_reserved) printf("\t\tReserved or Complete track\n");
if (is_blank) printf("\t\tBlank track\n");
if (is_packet_or_inc) printf("\t\tPacket mode track\n");
@@ -1295,7 +1296,7 @@ void dump_formatted_toc(void) {
void dump_raw_toc_pma_data(uint8_t *toc) {
int pos, data_length;
- int cur_session, session, cntrl, addr, tno, point;
+ int cur_session, session, cntrl, addr, point;
int min, sec, frame, pmin, psec, pframe, nwa, lba, extent;
data_length = toc[1] | (toc[0] << 8);
@@ -1304,7 +1305,7 @@ void dump_raw_toc_pma_data(uint8_t *toc) {
session = read_cd_bcd(toc[pos+ 0]);
cntrl = toc[pos+1] & 15;
addr = toc[pos+1] >> 4;
- tno = read_cd_bcd(toc[pos+ 2]);
+ //tno = read_cd_bcd(toc[pos+ 2]);
point = read_cd_bcd(toc[pos+ 3]);
min = read_cd_bcd(toc[pos+ 4]);
sec = read_cd_bcd(toc[pos+ 5]);
@@ -1420,14 +1421,13 @@ char *atip_speed(int speed) {
void dump_atip_data(uint8_t *toc) {
int pos, data_length;
- int cur_session;
int writing_power, ref_speed, URU, disc_cdrw, disc_subtype, A1, A2, A3;
int lowest_clv_rec, highest_clv_rec;
int power_multi, target_y, rec_EW_ratio, hicap_cdr_min;
int min, sec, frame, pmin, psec, pframe;
data_length = toc[1] | (toc[0] << 8);
- pos = 4; cur_session = 0;
+ pos = 4;
writing_power = (toc[pos ] >> 4) & 15;
ref_speed = toc[pos ] & 7;
@@ -1728,6 +1728,7 @@ void dump_parameter_page(uint8_t *pos, uint8_t *change) {
printf("\t\tData block type %s %s\n", prchange(change[4] & 15), print_data_block_type(data_block_type));
printf("\t\tTestwriting %s %s\n", prchange(change[2] & 16), testwrite ? "On":"Off");
printf("\t\tLinksize %s %d sectors (%s)\n", prchange(change[5]), link_size, linksize_valid ? "valid": "not valid (7)");
+ printf("\t\tZerolinking support %s %s\n", prchange(change[2] & 64), zerolinking ? "On":"Off");
printf("\t\tApplication code %s %d\n", prchange(change[7] & 63), appl_code);
printf("\t\tSession format %s %s\n", prchange(change[8]), print_session_format(session_format));
printf("\t\tUsing fixed packets %s %s\n", prchange(change[3] & 32), fixed_packets ? "On":"Off");
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..63bc9ab
--- /dev/null
+++ b/config.h
@@ -0,0 +1,2 @@
+#define yes
+
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..439db9b
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,2 @@
+#define @HAVE_SCSI@
+
diff --git a/configure b/configure
index c4b89e3..87a80b9 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for udfclient 0.8.1.
+# Generated by GNU Autoconf 2.69 for udfclient 0.8.5.
#
# Report bugs to <reinoud@NetBSD.org>.
#
@@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='udfclient'
PACKAGE_TARNAME='udfclient'
-PACKAGE_VERSION='0.8.1'
-PACKAGE_STRING='udfclient 0.8.1'
+PACKAGE_VERSION='0.8.5'
+PACKAGE_STRING='udfclient 0.8.5'
PACKAGE_BUGREPORT='reinoud@NetBSD.org'
PACKAGE_URL=''
@@ -1239,7 +1239,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures udfclient 0.8.1 to adapt to many kinds of systems.
+\`configure' configures udfclient 0.8.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1304,7 +1304,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of udfclient 0.8.1:";;
+ short | recursive ) echo "Configuration of udfclient 0.8.5:";;
esac
cat <<\_ACEOF
@@ -1384,7 +1384,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-udfclient configure 0.8.1
+udfclient configure 0.8.5
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1810,7 +1810,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by udfclient $as_me 0.8.1, which was
+It was created by udfclient $as_me 0.8.5, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3154,7 +3154,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
#
case $host_os in
linux*)
- CPPFLAGS="$CPPFLAGS -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -D__USE_BSD -D_FILE_OFFSET_BITS=64"
+ CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -D__USE_BSD -D_FILE_OFFSET_BITS=64"
;;
darwin*)
# CPPFLAGS="-D_POSIX_C_SOURCE"
@@ -4537,7 +4537,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by udfclient $as_me 0.8.1, which was
+This file was extended by udfclient $as_me 0.8.5, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -4590,7 +4590,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-udfclient config.status 0.8.1
+udfclient config.status 0.8.5
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index f375ee9..0ce1e1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
-AC_INIT([udfclient], [0.8.1], [reinoud@NetBSD.org])
+AC_INIT([udfclient], [0.8.5], [reinoud@NetBSD.org])
#AC_CONFIG_SRCDIR([udf.c])
AC_CANONICAL_HOST
#AC_CONFIG_HEADER([config.h])
@@ -20,7 +20,7 @@ AC_PROG_INSTALL
#
case $host_os in
linux*)
- CPPFLAGS="$CPPFLAGS -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -D__USE_BSD -D_FILE_OFFSET_BITS=64"
+ CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -D__USE_BSD -D_FILE_OFFSET_BITS=64"
;;
darwin*)
# CPPFLAGS="-D_POSIX_C_SOURCE"
diff --git a/defs.h b/defs.h
index ce773ea..0b9d2de 100644
--- a/defs.h
+++ b/defs.h
@@ -2,7 +2,7 @@
/*
* File "udf.h" is part of the UDFclient toolkit.
- * File $Id: defs.h,v 1.7 2015/01/02 21:23:18 reinoud Exp $ $Name: $
+ * File $Id: defs.h,v 1.8 2016/04/26 19:35:20 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -72,7 +72,7 @@ extern int udf_verbose;
/* DON'T change these: they identify 13thmonkey's UDF toolkit */
#define APP_NAME "*UDFtoolkit"
#define APP_VERSION_MAIN 0
-#define APP_VERSION_SUB 7
+#define APP_VERSION_SUB 8
#define IMPL_NAME "*13thMonkey UDFtoolkit"
/* RW content hint for allocation and other purposes */
diff --git a/ecma167-udf.h b/ecma167-udf.h
index 73c72b7..5b2ac55 100644
--- a/ecma167-udf.h
+++ b/ecma167-udf.h
@@ -265,7 +265,10 @@ struct regid {
struct icb_tag {
uint32_t prev_num_dirs;
uint16_t strat_type;
- uint8_t strat_param[2];
+ union {
+ uint8_t strat_param[2];
+ uint16_t strat_param16;
+ } __packed;
uint16_t max_num_entries;
uint8_t reserved;
uint8_t file_type;
@@ -683,7 +686,10 @@ struct impl_extattr_entry {
struct extattr_entry hdr;
uint32_t iu_l;
struct regid imp_id;
- uint8_t data[1];
+ union {
+ uint8_t data[1];
+ uint16_t data16;
+ } __packed;
} __packed;
diff --git a/mmc_format.c b/mmc_format.c
index 464c023..4688007 100644
--- a/mmc_format.c
+++ b/mmc_format.c
@@ -2,7 +2,7 @@
/*
* File "mmc_format.c" is part of the UDFclient toolkit.
- * File $Id: mmc_format.c,v 1.14 2015/08/05 18:26:29 reinoud Exp $ $Name: $
+ * File $Id: mmc_format.c,v 1.15 2016/04/25 21:01:39 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -515,11 +515,8 @@ uscsi_format_cdrw_mode7(struct uscsi_dev *dev, uint32_t blocks)
{
scsicmd cmd;
struct uscsi_sense sense;
- uint32_t param;
uint8_t buffer[16];
- int cnt, error;
-
- param = cnt = 0;
+ int error;
if (blocks % 32) {
blocks -= blocks % 32;
diff --git a/newfs_udf.c b/newfs_udf.c
index de340bf..20444de 100644
--- a/newfs_udf.c
+++ b/newfs_udf.c
@@ -2,7 +2,7 @@
/*
* File "newfs_udf.c" is part of the UDFclient toolkit.
- * File $Id: newfs_udf.c,v 1.44 2015/08/05 18:26:29 reinoud Exp $ $Name: $
+ * File $Id: newfs_udf.c,v 1.45 2016/04/25 21:01:39 reinoud Exp $ $Name: $
*
* Copyright (c) 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <errno.h>
#include <time.h>
+#include <sys/time.h>
#include "udf.h"
#include "udf_bswap.h"
diff --git a/udf.c b/udf.c
index bdb539a..826078f 100644
--- a/udf.c
+++ b/udf.c
@@ -2,7 +2,7 @@
/*
* File "udf.c" is part of the UDFclient toolkit.
- * File $Id: udf.c,v 1.294 2015/08/05 18:26:29 reinoud Exp $ $Name: $
+ * File $Id: udf.c,v 1.296 2016/04/25 21:27:59 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -542,6 +542,7 @@ int udf_vpartoff_to_sessionoff(struct udf_log_vol *udf_log_vol, struct udf_part_
eff_offset = offset % lb_size;
/* TODO check range for logical sector against VAT length */
+ assert(eff_sector < vat_entries);
trans_sector = vat_pos[eff_sector];
*ses_off = part_start + (trans_sector * lb_size) + eff_offset; /* trans sectors are in lb->lb ? */
*trans_valid_len = lb_size - eff_offset; /* maximum one logical sector */
@@ -1145,9 +1146,9 @@ int udf_init_udf_node(struct udf_mountpoint *mountpoint, struct udf_log_vol *udf
descr_ver = udf_rw16(udf_log_vol->log_vol->tag.descriptor_ver);
if (descr_ver == 2) {
/* TODO reserve some space for the icb creation time */
- data_space_avail = udf_log_vol->lb_size - sizeof(struct file_entry) - 0; /* udf_rw32(file_entry->l_ea) */
+ data_space_avail = lb_size - sizeof(struct file_entry) - 0; /* udf_rw32(file_entry->l_ea) */
} else {
- data_space_avail = udf_log_vol->lb_size - sizeof(struct extfile_entry) - 0; /* udf_rw32(extfile_entry->l_ea) */
+ data_space_avail = lb_size - sizeof(struct extfile_entry) - 0; /* udf_rw32(extfile_entry->l_ea) */
}
udf_node->intern_free = data_space_avail;
udf_node->intern_data = NULL;
@@ -1224,7 +1225,6 @@ int udf_readin_anon_udf_node(struct udf_log_vol *udf_log_vol, union dscrptr *giv
uint32_t lb_num, vpart_num;
uint32_t icb_len;
int16_t addr_type;
- uint8_t *file_data_pos;
uint8_t *pos;
uint8_t flags;
int error, advance_sector;
@@ -1291,7 +1291,6 @@ int udf_readin_anon_udf_node(struct udf_log_vol *udf_log_vol, union dscrptr *giv
next_alloc->vpart_num = udf_rw16(udf_icbptr->loc.part_num);
entries = 1;
- file_data_pos = NULL;
calculated_len = 0;
error = 0;
@@ -3071,12 +3070,11 @@ void udf_add_sparable_to_logvol(struct logvol_desc *logvol, uint16_t vol_seq_num
/* not called often; free incomming when not needed */
int udf_proc_log_vol(struct udf_pri_vol *primary, struct udf_log_vol **current, struct logvol_desc *incomming) {
- struct udf_mountpoint *mp;
struct udf_log_vol *logical;
struct udf_part_mapping *part_mapping, *data_part_mapping;
union udf_pmap *pmap;
uint32_t part_cnt, pmap_type, pmap_size;
- uint32_t data_part_num;
+ int32_t data_part_num;
uint8_t *pmap_pos;
logical = udf_search_logical_volume_in_primary(primary, incomming->logvol_id);
@@ -3589,10 +3587,8 @@ int udf_retrieve_supporting_tables(struct udf_log_vol *udf_log_vol) {
struct long_ad udf_icbptr;
union dscrptr *possible_vat_fe;
union dscrptr *sparing_table_dscr;
- uint8_t *vat;
uint32_t spar_loc;
uint64_t first_vat_loc, vat_loc, last_vat_loc;
- uint32_t vat_part;
uint32_t sector_size, lb_size;
int part_num, spar_num, data_part_num, vpart_num;
int session_num;
@@ -3635,7 +3631,6 @@ int udf_retrieve_supporting_tables(struct udf_log_vol *udf_log_vol) {
continue;
}
- vat = NULL; vat_part = 0;
if (udf_session->disc->next_writable[session_num]) {
last_vat_loc = udf_session->disc->next_writable[session_num];
} else {
@@ -4344,7 +4339,7 @@ int udf_sync_space_tables(struct udf_log_vol *udf_log_vol) {
union dscrptr *dscrptr;
uint64_t length;
uint32_t sector;
- uint32_t lb_size, part_start, part_len;
+ uint32_t lb_size, part_len;
uint16_t dscr_ver;
int part_num;
int error;
@@ -4361,7 +4356,7 @@ int udf_sync_space_tables(struct udf_log_vol *udf_log_vol) {
assert(udf_partition);
part_hdr_desc = &udf_partition->partition->pd_part_hdr;
- part_start = udf_rw32(udf_partition->partition->start_loc);
+ // part_start = udf_rw32(udf_partition->partition->start_loc);
part_len = udf_rw32(udf_partition->partition->part_len);
dscr_ver = udf_rw16(udf_partition->partition->tag.descriptor_ver);
@@ -5129,7 +5124,7 @@ static void udf_process_session_range(struct udf_discinfo *disc, int *enabled, i
/* range is specified in -3,5,7 or 5-6,8- etc */
static int udf_process_session_range_string(struct udf_discinfo *disc, char *range) {
- struct udf_session *udf_session, *next_udf_session, *last_ok;
+ struct udf_session *udf_session, *next_udf_session;
char *pos, *nop;
int low, high, len, session;
int enabled[MAX_SESSIONS];
@@ -5192,7 +5187,6 @@ static int udf_process_session_range_string(struct udf_discinfo *disc, char *ran
DEBUG(printf("UDF range matching : all ok till the end\n"));
if (!disc) return 0;
- last_ok = NULL;
udf_session = STAILQ_FIRST(&disc->sessions);
while (udf_session) {
next_udf_session = STAILQ_NEXT(udf_session, next_session);
@@ -5523,7 +5517,7 @@ int udf_readdir(struct udf_node *dir_node, struct uio *result_uio, int *eof_res
struct dirent dirent;
uint64_t diroffset, transoffset;
uint32_t lb_size;
- int eof, enough;
+ int eof;
int error;
assert(eof_res);
@@ -5592,7 +5586,7 @@ int udf_readdir(struct udf_node *dir_node, struct uio *result_uio, int *eof_res
free(fid);
- eof = (result_uio->uio_offset >= (uint64_t) dir_node->stat.st_size);
+ eof = (result_uio->uio_offset >= (int64_t) dir_node->stat.st_size);
if (eof_res) *eof_res = 1;
*eof_res = eof;
@@ -5673,6 +5667,7 @@ dirhash_fill(struct udf_node *dir_node)
}
+/* XXX yes, move namelen to unsigned int */
int udf_lookup_name_in_dir(struct udf_node *dir_node, char *name, int namelen, struct long_ad *icb_loc, struct fileid_desc *fid, int *found) {
struct dirhash *dirh;
struct dirhash_entry *dirh_ep;
@@ -5721,7 +5716,7 @@ int udf_lookup_name_in_dir(struct udf_node *dir_node, char *name, int namelen, s
(int) DIRENT_NAMLEN(dirent), (int) DIRENT_NAMLEN(dirent), dirent->d_name));
/* see if its our entry */
- assert(DIRENT_NAMLEN(dirent) == namelen);
+ assert(DIRENT_NAMLEN(dirent) == (unsigned int) namelen);
if (strncmp(dirent->d_name, name, namelen) == 0) {
*found = 1;
*icb_loc = fid->icb;
@@ -6257,7 +6252,7 @@ int udf_unlink_node(struct udf_node *udf_node) {
struct udf_allocentry *alloc_entry;
uint32_t lbnum, len;
uint16_t vpart;
- int error, flags;
+ int error;
/* just in case its called from outside */
if (udf_open_logvol(udf_node->udf_log_vol))
@@ -6278,7 +6273,7 @@ int udf_unlink_node(struct udf_node *udf_node) {
TAILQ_FOREACH(alloc_entry, &udf_node->dscr_allocs, next_alloc) {
vpart = alloc_entry->vpart_num;
lbnum = alloc_entry->lb_num;
- flags = alloc_entry->flags;
+ /* flags = alloc_entry->flags; */
len = alloc_entry->len;
error = udf_release_lbs(udf_node->udf_log_vol, vpart, lbnum, len);
@@ -6302,7 +6297,7 @@ static int udf_remove_directory_entry(struct udf_node *dir_node, struct udf_node
struct dirhash_entry *dirh_ep;
struct fileid_desc *fid;
struct dirent *dirent;
- uint64_t file_size, diroffset;
+ uint64_t diroffset;
uint32_t lb_size, namelen, fidsize;
int hit, found;
int error;
@@ -6336,9 +6331,6 @@ static int udf_remove_directory_entry(struct udf_node *dir_node, struct udf_node
}
dirh = dir_node->dir_hash;
- /* get directory filesize */
- file_size = dir_node->stat.st_size;
-
/* allocate temporary space for fid */
lb_size = udf_node->udf_log_vol->lb_size;
fid = malloc(lb_size);
diff --git a/udf_allocentries.c b/udf_allocentries.c
index 41e8e73..3c64f20 100644
--- a/udf_allocentries.c
+++ b/udf_allocentries.c
@@ -2,7 +2,7 @@
/*
* File "udf_allocentries.c" is part of the UDFclient toolkit.
- * File $Id: udf_allocentries.c,v 1.12 2011/02/01 20:43:40 reinoud Exp $ $Name: $
+ * File $Id: udf_allocentries.c,v 1.13 2016/04/25 21:01:40 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -206,7 +206,6 @@ int udf_cut_allocentry_queue(struct udf_alloc_entries *queue, uint32_t lb_size,
int udf_splitup_allocentry_queue(struct udf_alloc_entries *queue, uint32_t lb_size, uint64_t data_offset, uint64_t data_length, struct udf_allocentry **res_firstae, struct udf_allocentry **res_lastae) {
struct udf_allocentry *entry, *prev_entry;
uint64_t cur_offset, len;
- int error;
entry = prev_entry = NULL;
#if 0
@@ -219,8 +218,8 @@ int udf_splitup_allocentry_queue(struct udf_alloc_entries *queue, uint32_t lb_si
#endif
/* cut the string at the specified places */
- error = udf_cut_allocentry_queue(queue, lb_size, data_offset);
- error = udf_cut_allocentry_queue(queue, lb_size, data_offset + data_length);
+ (void) udf_cut_allocentry_queue(queue, lb_size, data_offset);
+ (void) udf_cut_allocentry_queue(queue, lb_size, data_offset + data_length);
#if 0
printf("POST SPLIT\n");
diff --git a/udf_bmap.c b/udf_bmap.c
index 2f182e1..c49d4ed 100644
--- a/udf_bmap.c
+++ b/udf_bmap.c
@@ -2,7 +2,7 @@
/*
* File "udf_bmap.c" is part of the UDFclient toolkit.
- * File $Id: udf_bmap.c,v 1.27 2015/05/04 21:14:54 reinoud Exp $ $Name: $
+ * File $Id: udf_bmap.c,v 1.28 2016/04/25 21:01:40 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -159,7 +159,7 @@ static int udf_allocate_lbs_on_partition(struct udf_log_vol *udf_log_vol, uint16
struct udf_partition *udf_partition;
struct udf_part_mapping *udf_part_mapping;
struct udf_alloc_entries *queue;
- uint64_t part_start, part_length;
+ uint64_t part_length;
uint64_t metadata_granularity, metadata_blk_len;
uint64_t part_offset;
uint32_t lb_size, num_lbs;
@@ -172,7 +172,7 @@ static int udf_allocate_lbs_on_partition(struct udf_log_vol *udf_log_vol, uint16
error = udf_logvol_vpart_to_partition(udf_log_vol, vpart_num, &udf_part_mapping, &udf_partition);
if (error) return error;
- part_start = (uint64_t) lb_size * udf_rw32(udf_partition->partition->start_loc);
+ // part_start = (uint64_t) lb_size * udf_rw32(udf_partition->partition->start_loc);
part_length = (uint64_t) lb_size * udf_rw32(udf_partition->partition->part_len);
req_size = (uint64_t) lb_size * req_lbs;
@@ -245,14 +245,13 @@ static int udf_allocate_lbs_on_partition(struct udf_log_vol *udf_log_vol, uint16
int udf_allocate_lbs(struct udf_log_vol *udf_log_vol, int content, uint32_t req_lbs, char *what, uint16_t *res_vpart_num, uint32_t *res_start_lb, uint32_t *res_num_lbs) {
struct udf_partition *udf_partition;
struct udf_part_mapping *udf_part_mapping;
- uint32_t lb_size, num_lbs;
+ uint32_t num_lbs;
uint16_t vpart_num;
int is_meta, ok;
int error;
assert(udf_log_vol);
num_lbs = 0; /* shutup gcc */
- lb_size = udf_log_vol->lb_size;
/* select udf partition to write to depending on the contents */
is_meta = ((content == UDF_C_FIDS) || (content == UDF_C_NODE));
diff --git a/udf_discop.c b/udf_discop.c
index 248a0c1..12e6cce 100644
--- a/udf_discop.c
+++ b/udf_discop.c
@@ -2,7 +2,7 @@
/*
* File "udf_discinfo.c" is part of the UDFclient toolkit.
- * File $Id: udf_discop.c,v 1.79 2015/08/05 18:26:31 reinoud Exp $ $Name: $
+ * File $Id: udf_discop.c,v 1.80 2016/04/25 21:01:40 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -36,6 +36,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
#include <unistd.h>
#include <assert.h>
#include <dirent.h>
@@ -698,6 +699,9 @@ int udf_discinfo_get_disc_type(struct udf_discinfo *disc) {
return error;
}
+ /* shutup gcc */
+ feature_pers = feature_pers; feature_ver = feature_ver;
+
return 0;
}
@@ -1054,6 +1058,10 @@ int udf_get_disc_info(struct udf_discinfo *disc) {
session = disc->num_sessions-1;
disc->session_end[session] = res[3] | (res[2]<<8) | (res[1]<<16) | (res[0]<<24);
+ /* shut up gcc */
+ disc_size = disc_size; first_track_last_session = first_track_last_session;
+ cntrl = cntrl; last_track = last_track;
+
return 0;
}
#undef res_len
diff --git a/udf_readwrite.c b/udf_readwrite.c
index 83caf29..070ab0e 100644
--- a/udf_readwrite.c
+++ b/udf_readwrite.c
@@ -2,7 +2,7 @@
/*
* File "udf_readwrite.c" is part of the UDFclient toolkit.
- * File $Id: udf_readwrite.c,v 1.49 2011/02/01 20:43:41 reinoud Exp $ $Name: $
+ * File $Id: udf_readwrite.c,v 1.50 2016/04/25 21:01:40 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -229,7 +229,7 @@ int udf_read_session_sector(struct udf_session *udf_session, uint32_t sector, ch
int udf_writeout_session_cache(struct udf_session *udf_session) {
struct udf_wrcallback *callback;
- uint32_t bit, write_bits, error_bits, sector_size;
+ uint32_t bit, error_bits, sector_size;
uint32_t num_sectors;
int32_t cache_diff;
uint32_t start_sector;
@@ -284,7 +284,6 @@ int udf_writeout_session_cache(struct udf_session *udf_session) {
if (udf_session->cache_line_w_present != UDF_READWRITE_ALL_PRESENT) {
/* count number of sectors present * (SEQUENTIAL?) */
start_sector = 0;
- write_bits = 0;
cache_diff = 0;
DEBUG(printf("Writing out non complete line\n"));
@@ -417,7 +416,7 @@ int udf_read_logvol_sector(struct udf_log_vol *udf_log_vol, uint32_t vpart_num,
uint32_t length, trans_length, trans_sectors, readahead;
uint32_t lb_size, sector_size;
uint32_t ses_sector, ses_offset;
- int error, resolved;
+ int error;
lb_size = udf_log_vol->lb_size;
sector_size = udf_log_vol->sector_size;
@@ -436,7 +435,6 @@ int udf_read_logvol_sector(struct udf_log_vol *udf_log_vol, uint32_t vpart_num,
udf_session = udf_partition->udf_session;
do {
trans_length = length;
- resolved = 0;
ses_sector = 0;
/* TODO optimalisation: could use `trans_valid_len' and `prefetch_sectors' */
@@ -512,7 +510,7 @@ int udf_write_logvol_sector(struct udf_log_vol *udf_log_vol, uint32_t vpart_num,
uint32_t lb_size, sector_size;
uint32_t ses_sector, ses_offset;
uint32_t fid_pos, max_fid_pos;
- int error, resolved, has_fids, recalc_crc, file_type;
+ int error, has_fids, recalc_crc, file_type;
lb_size = udf_log_vol->lb_size;
sector_size = udf_log_vol->sector_size;
@@ -576,7 +574,6 @@ int udf_write_logvol_sector(struct udf_log_vol *udf_log_vol, uint32_t vpart_num,
udf_session = udf_partition->udf_session;
do {
trans_length = length;
- resolved = 0;
ses_sector = 0;
/* determine the translated address and its translation validity length */
@@ -746,7 +743,7 @@ int udf_read_logvol_descriptor(struct udf_log_vol *udf_log_vol, uint32_t vpart_n
static int udf_write_descriptor(struct udf_log_vol *udf_log_vol, uint32_t vpart_num, struct udf_session *udf_session, uint32_t lb_num, uint32_t dscr_lb_num, char *what, union dscrptr *dscr, struct udf_wrcallback *wrcallback) {
uint32_t dscr_length;
uint32_t sector_size;
- uint32_t cur_length, sector, num_sectors;
+ uint32_t sector, num_sectors;
uint8_t *pos;
int error, rwflags;
@@ -756,7 +753,6 @@ static int udf_write_descriptor(struct udf_log_vol *udf_log_vol, uint32_t vpart_
sector_size = udf_log_vol ? udf_log_vol->lb_size : (uint32_t) udf_session->disc->sector_size;
/* All discriptors have a mimimum size of one sector be it logical or physical */
- cur_length = sector_size;
num_sectors = 1;
dscr_length = udf_calc_tag_malloc_size(dscr, sector_size);
diff --git a/udf_unix.c b/udf_unix.c
index 3a24b59..80f82ec 100644
--- a/udf_unix.c
+++ b/udf_unix.c
@@ -2,7 +2,7 @@
/*
* File "udf_unix.c" is part of the UDFclient toolkit.
- * File $Id: udf_unix.c,v 1.16 2015/08/05 18:26:31 reinoud Exp $
+ * File $Id: udf_unix.c,v 1.17 2016/04/25 21:01:40 reinoud Exp $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -272,7 +272,6 @@ void udf_mark_buf_clean(struct udf_node *udf_node, struct udf_buf *buf_entry) {
/* !!! needs to be called with bufcache and udf_node->buf_mutex lock !!! */
int udf_attach_buf_to_node(struct udf_node *udf_node, struct udf_buf *buf_entry) {
struct udf_buf_queue *lru_chain;
- struct udf_log_vol *log_vol;
struct udf_buf *buf, *lbuf;
uint32_t hashkey, bucket;
@@ -280,7 +279,6 @@ int udf_attach_buf_to_node(struct udf_node *udf_node, struct udf_buf *buf_entry)
assert(buf_entry);
assert(udf_node->buf_mutex.locked && udf_bufcache->bufcache_lock.locked);
- log_vol = udf_node->udf_log_vol;
buf_entry->b_vp = udf_node;
if (0) {
@@ -344,7 +342,6 @@ if (0) {
/* !!! needs to be called with bufcache and udf_node->buf_mutex lock !!! */
int udf_detach_buf_from_node(struct udf_node *udf_node, struct udf_buf *buf_entry) {
struct udf_buf_queue *lru_chain;
- uint32_t hashkey, bucket;
assert(udf_node);
assert(buf_entry);
@@ -358,8 +355,6 @@ int udf_detach_buf_from_node(struct udf_node *udf_node, struct udf_buf *buf_entr
udf_node->v_numoutput--;
/* remove from buffer cache */
- hashkey = udf_calc_bufhash(udf_node, buf_entry->b_lblk);
- bucket = hashkey & UDF_BUFCACHE_HASHMASK;
LIST_REMOVE(buf_entry, b_hash);
/* remove from lru lists */
@@ -379,7 +374,9 @@ int udf_detach_buf_from_node(struct udf_node *udf_node, struct udf_buf *buf_entr
/* bufcache lock has to be held! */
int udf_lookup_node_buf(struct udf_node *udf_node, uint32_t lblk, struct udf_buf **buf_p) {
+#ifdef UDF_METADATA_LRU
struct udf_buf_queue *lru_chain;
+#endif
struct udf_buf *buf;
uint32_t hashkey, bucket;
@@ -394,10 +391,10 @@ int udf_lookup_node_buf(struct udf_node *udf_node, uint32_t lblk, struct udf_buf
if ((buf->b_vp == udf_node) && (buf->b_lblk == lblk)) {
*buf_p = buf;
+#ifdef UDF_METADATA_LRU
lru_chain = &udf_bufcache->lru_bufs_data;
if (udf_node->udf_filetype != UDF_ICB_FILETYPE_RANDOMACCESS) lru_chain = &udf_bufcache->lru_bufs_metadata;
-#ifdef UDF_METADATA_LRU
TAILQ_REMOVE(lru_chain, buf, b_lru);
TAILQ_INSERT_TAIL(lru_chain, buf, b_lru);
#endif
diff --git a/udf_verbose.c b/udf_verbose.c
index 8a1680b..da7a763 100644
--- a/udf_verbose.c
+++ b/udf_verbose.c
@@ -2,7 +2,7 @@
/*
* File "udf_verbose.c" is part of the UDFclient toolkit.
- * File $Id: udf_verbose.c,v 1.117 2015/08/05 18:26:31 reinoud Exp $ $Name: $
+ * File $Id: udf_verbose.c,v 1.118 2016/04/25 21:01:40 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -575,7 +575,7 @@ void udf_dump_icb_tag(struct icb_tag *icb_tag) {
uint32_t flags, strat_param16;
flags = udf_rw16(icb_tag->flags);
- strat_param16 = udf_rw16(* (uint16_t *) icb_tag->strat_param);
+ strat_param16 = udf_rw16(icb_tag->strat_param16);
printf("\t\tICB Prior direct entries recorded (excl.) %d\n", udf_rw32(icb_tag->prev_num_dirs));
printf("\t\tICB Strategy type %d\n", udf_rw16(icb_tag->strat_type));
printf("\t\tICB Strategy type flags %d %d\n", icb_tag->strat_param[0], icb_tag->strat_param[1]);
@@ -733,7 +733,7 @@ void udf_dump_extattrseq(uint8_t *start, uint32_t offset, uint32_t impl_offset,
case 2048 : /* [4/48.10.9] implementation use extended attributes */
impl_extattr = (struct impl_extattr_entry *) pos;
iu_l = udf_rw32(impl_extattr->iu_l);
- chksum = udf_rw16(*((uint16_t *) impl_extattr->data));
+ chksum = udf_rw16(impl_extattr->data16);
printf("\t\t\tImplementation use extended attribute\n");
if (chksum != udf_ea_cksum(pos))
@@ -863,13 +863,11 @@ void udf_dump_file_entry(struct file_entry *fe) {
uint8_t *pos;
uint32_t length;
uint8_t addr_type;
- uint32_t entries;
- uint16_t strategy, strat_param16;
/* direct_entries = udf_rw32(fe->icbtag.prev_num_dirs); */
- strat_param16 = udf_rw16(* (uint16_t *) (fe->icbtag.strat_param));
- entries = udf_rw16(fe->icbtag.max_num_entries);
- strategy = udf_rw16(fe->icbtag.strat_type);
+ //strat_param16 = udf_rw16(* (uint16_t *) (fe->icbtag.strat_param));
+ //entries = udf_rw16(fe->icbtag.max_num_entries);
+ //strategy = udf_rw16(fe->icbtag.strat_type);
addr_type = udf_rw16(fe->icbtag.flags) & UDF_ICB_TAG_FLAGS_ALLOC_MASK;
printf("\tFile entry\n");
@@ -913,13 +911,11 @@ void udf_dump_extfile_entry(struct extfile_entry *efe) {
uint8_t *pos;
uint32_t length;
uint8_t addr_type;
- uint32_t entries;
- uint16_t strategy, strat_param16;
/* direct_entries = udf_rw32(efe->icbtag.prev_num_dirs); */
- strat_param16 = udf_rw16(* (uint16_t *) (efe->icbtag.strat_param));
- entries = udf_rw16(efe->icbtag.max_num_entries);
- strategy = udf_rw16(efe->icbtag.strat_type);
+ //strat_param16 = udf_rw16(* (uint16_t *) (efe->icbtag.strat_param));
+ //entries = udf_rw16(efe->icbtag.max_num_entries);
+ //strategy = udf_rw16(efe->icbtag.strat_type);
addr_type = udf_rw16(efe->icbtag.flags) & UDF_ICB_TAG_FLAGS_ALLOC_MASK;
printf("\tExtended file entry\n");
diff --git a/udfclient.c b/udfclient.c
index aa7632b..3da1acb 100644
--- a/udfclient.c
+++ b/udfclient.c
@@ -2,7 +2,7 @@
/*
* File "udfclient.c" is part of the UDFclient toolkit.
- * File $Id: udfclient.c,v 1.102 2015/08/05 18:26:31 reinoud Exp $ $Name: $
+ * File $Id: udfclient.c,v 1.104 2016/04/25 21:28:00 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -390,12 +390,14 @@ void udfclient_ls(int args, char *arg1) {
void udfclient_pwd(int args) {
char pwd[1024];
+ char *res;
if (args) {
printf("Syntax: pwd\n");
return;
}
- getcwd(pwd, 1024);
+ res = getcwd(pwd, 1024);
+ assert(res);
printf("UDF working directory is %s\n", curdir.name);
printf("Current FS working directory %s\n", pwd);
}
@@ -414,7 +416,7 @@ void udfclient_free(int args) {
struct logvol_desc *lvd;
uint64_t part_size, unalloc_space, freed_space;
uint64_t total_space, free_space, await_alloc_space;
- uint32_t sector_size, lb_size;
+ uint32_t lb_size;
int part_num;
if (args) {
@@ -428,7 +430,7 @@ void udfclient_free(int args) {
}
lb_size = udf_log_vol->lb_size;
- sector_size = udf_log_vol->sector_size;
+ // sector_size = udf_log_vol->sector_size;
lvd = udf_log_vol->log_vol;
udf_dump_id("Logical volume ", 128, lvd->logvol_id, &lvd->desc_charset);
@@ -525,6 +527,7 @@ void udfclient_cd(int args, char *arg1) {
void udfclient_lcd(int args, char *arg1) {
char pwd[1024];
+ char *res;
if (args > 1) {
printf("Syntax: lcd [dir]\n");
@@ -538,7 +541,8 @@ void udfclient_lcd(int args, char *arg1) {
fprintf(stderr, "While trying to go to %s :", arg1);
perror("");
}
- getcwd(pwd, 1024);
+ res = getcwd(pwd, 1024);
+ assert(res);
printf("Changing local directory to %s\n", pwd);
}
@@ -571,7 +575,7 @@ int udfclient_get_file(struct udf_node *udf_node, char *fullsrcname, char *fulld
uint64_t file_length;
uint64_t start, now, then, eta;
uint64_t cur_speed, avg_speed, data_transfered;
- uint64_t file_block_size, file_transfer_size;
+ uint64_t file_block_size, file_transfer_size, written;
uint8_t *file_block;
char cur_txt[32], avg_txt[32], eta_txt[32];
int fileh, len;
@@ -648,7 +652,8 @@ int udfclient_get_file(struct udf_node *udf_node, char *fullsrcname, char *fulld
break;
}
- write(fileh, file_block, file_transfer_size);
+ written = write(fileh, file_block, file_transfer_size);
+ assert(written == file_transfer_size);
if ((getmtime() - now > 1000000) || ((uint64_t) file_uio.uio_offset >= file_length)) {
if (strlen(fulldstname) < 45) {
@@ -1547,7 +1552,7 @@ void udfclient_interact(void) {
clearerr(stdin);
*line = 0;
- fgets(line, 4096, stdin);
+ (void) fgets(line, 4096, stdin);
if ((*line == 0) && feof(stdin)) {
printf("quit\n");
diff --git a/udfdump.c b/udfdump.c
index 1543c4f..cec7e9a 100644
--- a/udfdump.c
+++ b/udfdump.c
@@ -2,7 +2,7 @@
/*
* File "udfdump.c" is part of the UDFclient toolkit.
- * File $Id: udfdump.c,v 1.74 2011/02/01 20:43:41 reinoud Exp $ $Name: $
+ * File $Id: udfdump.c,v 1.75 2016/04/25 21:01:41 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
@@ -174,7 +174,6 @@ int main(int argc, char *argv[]) {
struct udf_discinfo *disc;
char *progname, *range;
uint32_t alt_sector_size;
- int min_session_number, max_session_number;
int flag, mntflags, bswap, error;
progname = argv[0];
@@ -227,9 +226,6 @@ int main(int argc, char *argv[]) {
if (argc == 0) return usage(progname);
- min_session_number = 0;
- max_session_number = 999;
-
/* all other arguments are devices */
udf_init();
while (argc) {
diff --git a/uscsi_subr.c.async b/uscsi_subr.c.async
deleted file mode 100644
index a7f0986..0000000
--- a/uscsi_subr.c.async
+++ /dev/null
@@ -1,608 +0,0 @@
-/* $NetBSD: uscsi_subr.c,v 1.7 2002/10/08 20:17:06 soren Exp $ */
-
-/*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace
- * Simulation Facility, NASA Ames Research Center.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
- *
- * Small changes, generalisations and Linux support by Reinoud Zandijk
- * <reinoud@netbsd.org>.
- *
- */
-
-
-/*
- * SCSI support subroutines.
- */
-
-#include <sys/param.h>
-#include <sys/ioctl.h>
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <inttypes.h>
-#include <assert.h>
-
-#include "uscsilib.h"
-
-
-int uscsilib_verbose = 1;
-
-
-#ifdef USCSI_SCSIPI
- /*
- * scsipi is a integrated SCSI and ATAPI layer under NetBSD and exists
- * in a modified form under OpenBSD and possibly also under other
- * operating systems.
- */
-
-
-#include <sys/scsiio.h>
-#ifdef __OpenBSD__
-#include <scsi/scsi_all.h>
-#else
-#include <dev/scsipi/scsipi_all.h>
-#endif
-
-
-int
-uscsi_open(struct uscsi_dev *disc)
-{
- struct stat stat;
- int flags, var;
-
- flags = O_RDWR | O_NONBLOCK | O_ASYNC;
- disc->fhandle = open(disc->dev_name, flags, 0); /* no create */
- if (disc->fhandle<0) {
- perror("Failure to open device or file");
- return ENODEV;
- }
-
- if (fstat(disc->fhandle, &stat) < 0) {
- perror("Can't stat device or file");
- uscsi_close(disc);
- return ENODEV;
- }
- flags = fcntl(disc->fhandle, F_GETFL, &var);
- if (flags & O_NONBLOCK)
- fprintf(stderr, "Device did open with O_NONBLOCK\n");
- return 0;
-}
-
-
-int
-uscsi_close(struct uscsi_dev * disc)
-{
- close(disc->fhandle);
- disc->fhandle = -1;
-
- return 0;
-}
-
-
-int
-uscsi_command(int flags, struct uscsi_dev *disc,
- void *cmd, size_t cmdlen, void *data, size_t datalen,
- uint32_t timeout, struct uscsi_sense *uscsi_sense)
-{
- scsireq_t req;
- int i;
-
- memset(&req, 0, sizeof(req));
- if (uscsi_sense)
- bzero(uscsi_sense, sizeof(struct uscsi_sense));
-
- memcpy(req.cmd, cmd, cmdlen);
- req.cmdlen = cmdlen;
- req.databuf = data;
- req.datalen = datalen;
- req.timeout = 1; //timeout;
- req.flags = flags;
- req.senselen = SENSEBUFLEN;
-
- /* test if unit is ready */
- for (i = 0; i < timeout/1; i++) {
- if (ioctl(disc->fhandle, SCIOCCOMMAND, &req) == -1)
- return EIO;
-
- if (req.retsts != SCCMD_TIMEOUT)
- break;
- }
- if (i > 0)
- printf("took %d tries\n", i+1);
-
- if (req.retsts == SCCMD_OK)
- return 0;
-
-fprintf(stderr, "%s : req.retsts %d\n", __func__, req.retsts);
- /* Some problem; report it and exit. */
- if (req.retsts == SCCMD_TIMEOUT) {
- if (uscsilib_verbose)
- fprintf(stderr, "%s: SCSI command timed out\n",
- disc->dev_name);
- return EAGAIN;
- } else if (req.retsts == SCCMD_BUSY) {
- if (uscsilib_verbose)
- fprintf(stderr, "%s: device is busy\n",
- disc->dev_name);
- return EBUSY;
- } else if (req.retsts == SCCMD_SENSE) {
- if (uscsi_sense) {
- uscsi_sense->asc = req.sense[12];
- uscsi_sense->ascq = req.sense[13];
- uscsi_sense->skey_valid = req.sense[15] & 128;
- uscsi_sense->sense_key = (req.sense[16] << 8) |
- (req.sense[17]);
- }
- if (uscsilib_verbose)
- uscsi_print_sense((char *) disc->dev_name,
- req.cmd, req.cmdlen,
- req.sense, req.senselen_used, 1);
- return EIO;
- } else
- if (uscsilib_verbose)
- fprintf(stderr, "%s: device had unknown status %x\n",
- disc->dev_name,
- req.retsts);
-
- return EFAULT;
-}
-
-
-/*
- * The reasoning behind this explicit copy is for compatibility with changes
- * in our uscsi_addr structure.
- */
-int
-uscsi_identify(struct uscsi_dev *disc, struct uscsi_addr *saddr)
-{
- struct scsi_addr raddr;
- int error;
-
- bzero(saddr, sizeof(struct scsi_addr));
- error = ioctl(disc->fhandle, SCIOCIDENTIFY, &raddr);
- if (error) {
- saddr->type = USCSI_TYPE_UNKNOWN;
- return error;
- }
-
-#ifdef __NetBSD__
- /* scsi and atapi are split up like in uscsi_addr */
- if (raddr.type == 0) {
- saddr->type = USCSI_TYPE_SCSI;
- saddr->addr.scsi.scbus = raddr.addr.scsi.scbus;
- saddr->addr.scsi.target = raddr.addr.scsi.target;
- saddr->addr.scsi.lun = raddr.addr.scsi.lun;
- } else {
- saddr->type = USCSI_TYPE_ATAPI;
- saddr->addr.atapi.atbus = raddr.addr.atapi.atbus;
- saddr->addr.atapi.drive = raddr.addr.atapi.drive;
- }
-#endif
-#ifdef __OpenBSD__
- /* atapi's are shown as SCSI devices */
- if (raddr.type == 0) {
- saddr->type = USCSI_TYPE_SCSI;
- saddr->addr.scsi.scbus = raddr.scbus;
- saddr->addr.scsi.target = raddr.target;
- saddr->addr.scsi.lun = raddr.lun;
- } else {
- saddr->type = USCSI_TYPE_ATAPI;
- saddr->addr.atapi.atbus = raddr.scbus; /* overload */
- saddr->addr.atapi.drive = raddr.target; /* overload */
- }
-#endif
-
- return 0;
-}
-
-#endif /* SCSILIB_SCSIPI */
-
-
-
-
-#ifdef USCSI_LINUX_SCSI
- /*
- * Support code for Linux SCSI code. It uses the ioctl() way of
- * communicating since this is more close to the origional NetBSD
- * scsipi implementation.
- */
-#include <scsi/sg.h>
-#include <scsi/scsi.h>
-
-#define SENSEBUFLEN 48
-
-
-int
-uscsi_open(struct uscsi_dev * disc)
-{
- int flags;
- struct stat stat;
-
- /* in Linux we are NOT allowed to open it blocking */
- /* no create! */
- disc->fhandle = open(disc->dev_name, O_RDWR | O_NONBLOCK, 0);
- if (disc->fhandle < 0)
- disc->fhandle = open(disc->dev_name, O_RDONLY | O_NONBLOCK, 0);
- if (disc->fhandle < 0) {
- perror("Failure to open device or file");
- return ENODEV;
- }
-
- /* explicitly mark it non blocking (again) (silly Linux) */
- flags = fcntl(disc->fhandle, F_GETFL);
- flags &= ~O_NONBLOCK;
- fcntl(disc->fhandle, F_SETFL, flags);
-
- if (fstat(disc->fhandle, &stat) < 0) {
- perror("Can't stat device or file");
- uscsi_close(disc);
- return ENODEV;
- }
-
- return 0;
-}
-
-
-int
-uscsi_close(struct uscsi_dev * disc)
-{
- close(disc->fhandle);
- disc->fhandle = -1;
-
- return 0;
-}
-
-
-int
-uscsi_command(int flags, struct uscsi_dev *disc,
- void *cmd, size_t cmdlen,
- void *data, size_t datalen,
- uint32_t timeout, struct uscsi_sense *uscsi_sense)
-{
- struct sg_io_hdr req;
- uint8_t sense_buffer[SENSEBUFLEN];
- int error;
-
- bzero(&req, sizeof(req));
- if (flags == SG_DXFER_FROM_DEV) bzero(data, datalen);
-
- req.interface_id = 'S';
- req.dxfer_direction = flags;
- req.cmd_len = cmdlen;
- req.mx_sb_len = SENSEBUFLEN;
- req.iovec_count = 0;
- req.dxfer_len = datalen;
- req.dxferp = data;
- req.cmdp = cmd;
- req.sbp = sense_buffer;
- req.flags = 0;
- req.timeout = timeout;
-
- error = ioctl(disc->fhandle, SG_IO, &req);
-
- if (req.status) {
- /* Is this OK? */
- if (uscsi_sense) {
- uscsi_sense->asc = sense_buffer[12];
- uscsi_sense->ascq = sense_buffer[13];
- uscsi_sense->skey_valid = sense_buffer[15] & 128;
- uscsi_sense->sense_key = (sense_buffer[16] << 8) |
- (sense_buffer[17]);
- }
- if (uscsilib_verbose) {
- uscsi_print_sense((char *) disc->dev_name,
- cmd, cmdlen, sense_buffer, req.sb_len_wr, 1);
- }
- }
-
- return error;
-}
-
-
-int
-uscsi_identify(struct uscsi_dev *disc, struct uscsi_addr *saddr)
-{
- struct sg_scsi_id sg_scsi_id;
- struct sg_id {
- /* target | lun << 8 | channel << 16 | low_ino << 24 */
- uint32_t tlci;
- uint32_t uniq_id;
- } sg_id;
- int emulated;
- int error;
-
- /* clean result */
- bzero(saddr, sizeof(struct uscsi_addr));
-
- /* check if its really SCSI or emulated SCSI (ATAPI f.e.) */
- saddr->type = USCSI_TYPE_SCSI;
- ioctl(disc->fhandle, SG_EMULATED_HOST, &emulated);
- if (emulated) saddr->type = USCSI_TYPE_ATAPI;
-
- /* try 2.4 kernel or older */
- error = ioctl(disc->fhandle, SG_GET_SCSI_ID, &sg_scsi_id);
- if (!error) {
- saddr->addr.scsi.target = sg_scsi_id.scsi_id;
- saddr->addr.scsi.lun = sg_scsi_id.lun;
- saddr->addr.scsi.scbus = sg_scsi_id.channel;
-
- return 0;
- }
-
- /* 2.6 kernel or newer */
- error = ioctl(disc->fhandle, SCSI_IOCTL_GET_IDLUN, &sg_id);
- if (error) return error;
-
- saddr->addr.scsi.target = (sg_id.tlci ) & 0xff;
- saddr->addr.scsi.lun = (sg_id.tlci >> 8) & 0xff;
- saddr->addr.scsi.scbus = (sg_id.tlci >> 16) & 0xff;
-
- return 0;
-}
-
-#endif /* USCSI_LINUX_SCSI */
-
-
-
-
-#ifdef USCSI_FREEBSD_CAM
-
-int
-uscsi_open(struct uscsi_dev *disc)
-{
- disc->devhandle = cam_open_device(disc->dev_name, O_RDWR);
-
- if (disc->devhandle == NULL) {
- disc->fhandle = open(disc->dev_name, O_RDWR | O_NONBLOCK, 0);
- if (disc->fhandle < 0) {
- perror("Failure to open device or file");
- return ENODEV;
- }
- }
-
- return 0;
-}
-
-
-int
-uscsi_close(struct uscsi_dev *disc)
-{
- if (disc->devhandle != NULL) {
- cam_close_device(disc->devhandle);
- disc->devhandle = NULL;
- } else {
- close(disc->fhandle);
- disc->fhandle = -1;
- }
-
- return 0;
-}
-
-
-int
-uscsi_command(int flags, struct uscsi_dev *disc,
- void *cmd, size_t cmdlen,
- void *data, size_t datalen,
- uint32_t timeout, struct uscsi_sense *uscsi_sense)
-{
- struct cam_device *cam_dev;
- struct scsi_sense_data *cam_sense_data;
- union ccb ccb;
- uint32_t cam_sense;
- uint8_t *keypos;
- int camflags;
-
- memset(&ccb, 0, sizeof(ccb));
- cam_dev = (struct cam_device *) disc->devhandle;
- if (cam_dev == 0)
- return EIO;
-
- if (datalen == 0) flags = SCSI_NODATACMD;
- /* optional : */
- /* if (data) assert(flags == SCSI_NODATACMD); */
-
- camflags = CAM_DIR_NONE;
- if (flags & SCSI_READCMD)
- camflags = CAM_DIR_IN;
- if (flags & SCSI_WRITECMD)
- camflags = CAM_DIR_OUT;
-
- cam_fill_csio(
- &ccb.csio,
- 0, /* retries */
- NULL, /* cbfcnp */
- camflags, /* flags */
- MSG_SIMPLE_Q_TAG, /* tag_action */
- (u_int8_t *) data, /* data_ptr */
- datalen, /* dxfer_len */
- SSD_FULL_SIZE, /* sense_len */
- cmdlen, /* cdb_len */
- timeout /* timeout */
- );
-
- /* Disable freezing the device queue */
- ccb.ccb_h.flags |= CAM_DEV_QFRZDIS;
-
- memcpy(ccb.csio.cdb_io.cdb_bytes, cmd, cmdlen);
-
- /* Send the command down via the CAM interface */
- if (cam_send_ccb(cam_dev, &ccb) < 0) {
- err(1, "cam_send_ccb");
- }
-
- if ((ccb.ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)
- return 0;
-
- /* print error using the uscsi_sense routines? */
-
- cam_sense = (ccb.ccb_h.status & (CAM_STATUS_MASK | CAM_AUTOSNS_VALID));
- if (cam_sense != (CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID))
- return EFAULT;
-
- /* drive responds with sense information */
- if (!uscsilib_verbose)
- return EFAULT;
-
- /* print sense info */
- cam_sense_data = &ccb.csio.sense_data;
- if (uscsi_sense) {
- uscsi_sense->asc = cam_sense_data->add_sense_code;
- uscsi_sense->ascq = cam_sense_data->add_sense_code_qual;
- keypos = cam_sense_data->sense_key_spec;
- uscsi_sense->skey_valid = keypos[0] & 128;
- uscsi_sense->sense_key = (keypos[1] << 8) | (keypos[2]);
- }
-
- uscsi_print_sense((char *) disc->dev_name,
- cmd, cmdlen,
- (uint8_t *) cam_sense_data, 8 + cam_sense_data->extra_len, 1);
-
- return EFAULT;
-}
-
-
-int
-uscsi_identify(struct uscsi_dev *disc, struct uscsi_addr *saddr)
-{
- struct cam_device *cam_dev;
-
- /* clean result */
- bzero(saddr, sizeof(struct uscsi_addr));
-
- cam_dev = (struct cam_device *) disc->devhandle;
- if (!cam_dev) return ENODEV;
-
- /* check if its really SCSI or emulated SCSI (ATAPI f.e.) ? */
- saddr->type = USCSI_TYPE_SCSI;
- saddr->addr.scsi.target = cam_dev->target_id;
- saddr->addr.scsi.lun = cam_dev->target_lun;
- saddr->addr.scsi.scbus = cam_dev->bus_id;
-
- return 0;
-}
-
-
-#endif /* USCSI_FREEBSD_CAM */
-
-
-/*
- * Checks if SCSI is available by issueing the obligatory INQUIRY.
- */
-
-int
-uscsi_check_for_scsi(struct uscsi_dev *disc)
-{
- scsicmd cmd;
- uint8_t buf[256];
- int error;
-
- bzero(cmd, SCSI_CMD_LEN);
- cmd[0] = 0x12; /* INQUIRY */
- cmd[1] = 0; /* basic inquiry */
- cmd[2] = 0; /* no page or operation code */
- cmd[3] = 0; /* reserved/MSB result */
- cmd[4] = 96; /* all but vendor specific */
- cmd[5] = 0; /* control */
- error = uscsi_command(SCSI_READCMD, disc, cmd, 6, buf, 96, 30000, NULL);
-
- return error;
-}
-
-
-/*
- * Generic SCSI funtions also used by the sense printing functionality.
- * FreeBSD support has it allready asked for by the CAM.
- */
-int
-uscsi_mode_sense(struct uscsi_dev *dev,
- uint8_t pgcode, uint8_t pctl, void *buf, size_t len)
-{
- scsicmd cmd;
-
- bzero(buf, len); /* initialise recieving buffer */
-
- bzero(cmd, SCSI_CMD_LEN);
- cmd[ 0] = 0x1a; /* MODE SENSE */
- cmd[ 1] = 0; /* - */
- cmd[ 2] = pgcode | pctl; /* page code and control flags */
- cmd[ 3] = 0; /* - */
- cmd[ 4] = len; /* length of recieve buffer */
- cmd[ 5] = 0; /* control */
-
- return uscsi_command(SCSI_READCMD, dev, &cmd, 6, buf, len, 10000, NULL);
-}
-
-
-int
-uscsi_mode_select(struct uscsi_dev *dev,
- uint8_t byte2, void *buf, size_t len)
-{
- scsicmd cmd;
-
- bzero(cmd, SCSI_CMD_LEN);
- cmd[ 0] = 0x15; /* MODE SELECT */
- cmd[ 1] = 0x10 | byte2; /* SCSI-2 page format select */
- cmd[ 4] = len; /* length of page settings */
- cmd[ 5] = 0; /* control */
-
- return uscsi_command(SCSI_WRITECMD, dev, &cmd, 6, buf, len,
- 10000, NULL);
-}
-
-
-int
-uscsi_request_sense(struct uscsi_dev *dev, void *buf, size_t len)
-{
- scsicmd cmd;
-
- bzero(buf, len); /* initialise recieving buffer */
-
- bzero(cmd, SCSI_CMD_LEN);
- cmd[ 0] = 0x03; /* REQUEST SENSE */
- cmd[ 4] = len; /* length of data to be read */
- cmd[ 5] = 0; /* control */
-
- return uscsi_command(SCSI_WRITECMD, dev, &cmd, 6, buf, len,
- 10000, NULL);
-}
-
-
-/* end of uscsi_subr.c */
-
diff --git a/vfs_dirhash.c b/vfs_dirhash.c
index a74922f..a3b7e51 100644
--- a/vfs_dirhash.c
+++ b/vfs_dirhash.c
@@ -179,13 +179,11 @@ dirhash_purge_entries(struct dirhash *dirh)
dirh_e = LIST_FIRST(&dirh->entries[hashline]);
}
}
- dirh_e = LIST_FIRST(&dirh->free_entries);
- while (dirh_e) {
+ while ((dirh_e = LIST_FIRST(&dirh->free_entries)) != NULL) {
LIST_REMOVE(dirh_e, next);
//pool_put(&dirhash_entry_pool, dirh_e);
free(dirh_e);
- dirh_e = LIST_FIRST(&dirh->entries[hashline]);
}
dirh->flags &= ~DIRH_COMPLETE;