NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/48808
The following reply was made to PR kern/48808; it has been noted by GNATS.
From: "Thomas Schmitt" <scdbackup%gmx.net@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: kern/48808
Date: Wed, 14 May 2014 11:04:44 +0200
--- sbin/mount_cd9660/mount_cd9660.c.orig 2011-08-29 14:35:00.000000000
+0000
+++ sbin/mount_cd9660/mount_cd9660.c 2014-05-13 19:09:42.000000000 +0000
@@ -59,6 +59,7 @@ __RCSID("$NetBSD: mount_cd9660.c,v 1.32
#include <string.h>
#include <unistd.h>
#include <util.h>
+#include <errno.h>
#include <isofs/cd9660/cd9660_mount.h>
@@ -79,6 +80,7 @@ static const struct mntopt mopts[] = {
{ "rrip", 1, ISOFSMNT_NORRIP, 1 },
{ "joliet", 1, ISOFSMNT_NOJOLIET, 1 },
{ "rrcaseins", 0, ISOFSMNT_RRCASEINS, 1 },
+ { "ssector", 0, 0, 1 }, /* not setable, only for info via getargs */
MOPT_NULL,
};
@@ -102,11 +104,15 @@ mount_cd9660_parseargs(int argc, char **
int ch, opts;
mntoptparse_t mp;
char *dev, *dir;
+#ifdef ISOFSMNT_SSECTOR
+ char *ep;
+ long long int llnum;
+#endif
memset(args, 0, sizeof(*args));
*mntflags = opts = 0;
optind = optreset = 1;
- while ((ch = getopt(argc, argv, "egijo:r")) != -1)
+ while ((ch = getopt(argc, argv, "egijo:rs:")) != -1)
switch (ch) {
case 'e':
/* obsolete, retained for compatibility only, use
@@ -134,6 +140,23 @@ mount_cd9660_parseargs(int argc, char **
* -o norrip */
opts |= ISOFSMNT_NORRIP;
break;
+ case 's':
+#ifdef ISOFSMNT_SSECTOR
+ /* learned from mount/fattr.c : a_num() */
+ llnum = strtoll(optarg, &ep, 0);
+ if (*ep || optarg == ep || llnum < 0 ||
+ llnum > (long long int) 0xffffff00) {
+ (void)fprintf(stderr,
+ "%s : unusable parameter with option -s\n",
+ getprogname());
+ usage();
+ }
+ args->ssector = llnum;
+ opts |= ISOFSMNT_SSECTOR;
+ break;
+#else
+ usage();
+#endif
case '?':
default:
usage();
@@ -161,6 +184,38 @@ mount_cd9660_parseargs(int argc, char **
args->flags = opts;
}
+#ifdef ISOFSMNT_SSECTOR
+
+/* Inquire after mount whether the running kernel knows iso_args.ssector.
+ * This cannot be done before mount(2), because then MNT_GETARGS will yield
+ * no result. Afterwards, the size of the MNT_GETARGS reply can tell.
+ */
+static int
+kernel_has_args_ssector(char *canon_dir)
+{
+ struct iso_args args;
+ int mntflags = MNT_GETARGS, kernel_args_size;
+
+ kernel_args_size = mount(MOUNT_CD9660, canon_dir, mntflags,
+ &args, sizeof args);
+ if (kernel_args_size == -1) {
+ (void)fprintf(stderr,
+ "%s : Error when inquiring success of option -s : %s\n",
+ getprogname(),
+ errno != 0 ? strerror(errno) : "unrecognizable error");
+ return 0;
+ }
+ if (kernel_args_size < (int) (sizeof (struct old_iso_args_v_1_6) +
+ sizeof (unsigned long int))) {
+ (void)fprintf(stderr, "%s : Kernel ignored option -s\n",
+ getprogname());
+ return 0;
+ }
+ return (1);
+}
+
+#endif /* ISOFSMNT_SSECTOR */
+
int
mount_cd9660(int argc, char **argv)
{
@@ -177,6 +232,20 @@ mount_cd9660(int argc, char **argv)
char buf[2048];
(void)snprintb(buf, sizeof(buf), ISOFSMNT_BITS, args.flags);
printf("%s\n", buf);
+
+#ifdef ISOFSMNT_SSECTOR
+
+ if (args.flags & ISOFSMNT_SSECTOR)
+ printf("-s %lu\n", args.ssector);
+ } else if ((args.flags & ISOFSMNT_SSECTOR) && args.ssector > 0) {
+ if (!kernel_has_args_ssector(canon_dir)) {
+ if (unmount(canon_dir, 0) == 0)
+ (void)fprintf(stderr,
+ "%s : Had to revoke mount attempt with option -s\n",
+ getprogname());
+ exit(1);
+ }
+#endif
}
exit(0);
@@ -185,7 +254,13 @@ mount_cd9660(int argc, char **argv)
static void
usage(void)
{
+#ifdef ISOFSMNT_SSECTOR
+ (void)fprintf(stderr,
+ "usage: %s [-o options | -s block_offset] special node\n",
+ getprogname());
+#else
(void)fprintf(stderr,
"usage: %s [-o options] special node\n", getprogname());
+#endif
exit(1);
}
--- sbin/mount_cd9660/mount_cd9660.8.orig 2009-01-03 22:56:23.000000000
+0000
+++ sbin/mount_cd9660/mount_cd9660.8 2014-05-13 18:34:13.000000000 +0000
@@ -57,7 +57,7 @@
.\"
.\" @(#)mount_cd9660.8 8.3 (Berkeley) 3/27/94
.\"
-.Dd January 3, 2009
+.Dd May, 12, 2014
.Dt MOUNT_CD9660 8
.Os
.Sh NAME
@@ -66,6 +66,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl o Ar options
+.Op Fl s Ar block_offset
.Ar special node
.Sh DESCRIPTION
The
@@ -130,8 +131,35 @@ For compatibility with Solaris only.
.It Cm rrcaseins
Makes all lookups case-insensitive even for CD-ROMs with Rock-Ridge
extensions (for Rock-Ridge, default is case-sensitive lookup).
+.It Cm ssector
+Is ignored as input option but reported by
+.Cm getargs
+if option
+.Cm Fl s
+is in effect.
.El
.El
+.Bl -tag -width indent
+.It Fl s Ar block_offset
+Read the superblock from a block address, which is computed by adding
+.Ar block_offset
+to the partition offset implied by the choice of the device file.
+With /dev/cdXd this partition offset is 0,
+which leads to the first and oldest ISO-9660 session on the medium.
+/dev/cdXa has the offset of the last and youngest recognized medium
+partition.
+Other sessions may be reached from /dev/cdXd by
+.Fl s
+with a
+.Ar block_offset
+which can be obtained from burn software for optical media.
+The block size is 2048 bytes.
+.Pp
+/dev/cdX partitions are recognized from logical tracks of unformatted
+optical media.
+Formatted media appear as a single partition. Nevertheless they may bear
+several ISO-9660 sessions. Refer to their ISO-9660 producer for offset info.
+.El
.Pp
For compatibility with previous releases, following obsolete flags are
still recognized:
Home |
Main Index |
Thread Index |
Old Index