diff --git a/udftools-1.0.0b3-mkudffs-bigendian.patch b/udftools-1.0.0b3-mkudffs-bigendian.patch new file mode 100644 index 0000000..3209262 --- /dev/null +++ b/udftools-1.0.0b3-mkudffs-bigendian.patch @@ -0,0 +1,36 @@ +Date: Sun, 12 Dec 2004 14:25:09 +0100 +From: Christoph Hellwig +To: submit@bugs.debian.org + +Package: udftools +Version: 1.0.0b3-6 + +mkduffs crashes with a segmentation fault when trying to create a +filesystem on big-endian systems. e.g. mkudffs /dev/sda4 on my +PowerMac. + +udffstools from CVS on sf.net is fine, and I've extracted the actual +fix: + + +diff -uNr -Xdontdiff -p udftools-1.0.0b3/mkudffs/mkudffs.c udftools/mkudffs/mkudffs.c +--- udftools-1.0.0b3/mkudffs/mkudffs.c 2004-02-23 04:35:33.000000000 +0100 ++++ udftools/mkudffs/mkudffs.c 2004-03-02 03:09:39.000000000 +0100 +@@ -250,14 +250,14 @@ void split_space(struct udf_disc *disc) + if (size % offsets[PSPACE_SIZE]) + size -= (size % offsets[PSPACE_SIZE]); + set_extent(disc, PSPACE, start, size); +- for (i=0; iudf_lvd[0]->numPartitionMaps; i++) ++ for (i=0; iudf_lvd[0]->numPartitionMaps); i++) + { + if (i == 1) + disc->udf_lvid->freeSpaceTable[i] = cpu_to_le32(0xFFFFFFFF); + else + disc->udf_lvid->freeSpaceTable[i] = cpu_to_le32(size); + } +- for (j=0; judf_lvd[0]->numPartitionMaps; j++) ++ for (j=0; judf_lvd[0]->numPartitionMaps); j++) + { + if (j == 1) + disc->udf_lvid->sizeTable[i+j] = cpu_to_le32(0xFFFFFFFF); + diff --git a/udftools-1.0.0b3-pktsetup-chardev.patch b/udftools-1.0.0b3-pktsetup-chardev.patch new file mode 100644 index 0000000..5ef0825 --- /dev/null +++ b/udftools-1.0.0b3-pktsetup-chardev.patch @@ -0,0 +1,346 @@ +From: Peter Osterlund +Subject: Re: [RFC][PATCH] Control pktcdvd with an auxiliary character device +To: linux-kernel@vger.kernel.org +Cc: Christoph Hellwig , Arnd Bergmann , + Jens Axboe , Andrew Morton +Date: Wed Jul 14 02:17:27 2004 +0200 + +Peter Osterlund writes: + +> Peter Osterlund writes: +> +> > Christoph Hellwig writes: +> > +> > > On Sun, Jul 11, 2004 at 01:20:45AM +0200, Arnd Bergmann wrote: +> > > > These are actually incorrect definitions since the ioctl argument is +> > > > not a pointer to unsigned int but instead just an int. However, that's +> > > > too late to fix without breaking the existing tools. +> > > +> > > The tools need to change anyway to get away from the broken behaviour to +> > > issue in ioctl on the actual block device to bind it.. +> > +> > OK, I'll create a patch that gets rid of the ioctl interface and uses +> > an auxiliary character device instead to control device bindings. +> +> Here is a patch for 2.6.7-mm7 that does that. The driver creates a +> misc character device and bind/unbind of the block devices are +> controlled by ioctl commands on the char device. +> +> This patch needs corresponding changes in the pktsetup user space +> program. I'll post a patch for pktsetup as a separate message. + +And here is a patch for udftools-1.0.0b3 that updates the pktsetup +program to make it able to use the character device for block device +setup/teardown. + +--- + + udftools-1.0.0b3-petero/pktsetup/pktsetup.c | 245 +++++++++++++++++++++++++++- + 1 files changed, 238 insertions(+), 7 deletions(-) + +diff -puN pktsetup/pktsetup.c~pktsetup-char-dev pktsetup/pktsetup.c +--- udftools-1.0.0b3/pktsetup/pktsetup.c~pktsetup-char-dev 2004-07-12 19:57:51.000000000 +0200 ++++ udftools-1.0.0b3-petero/pktsetup/pktsetup.c 2004-07-14 00:34:02.471317888 +0200 +@@ -1,5 +1,6 @@ + /* + * Copyright (c) 1999,2000 Jens Axboe ++ * Copyright (c) 2004 Peter Osterlund + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -19,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -33,8 +35,33 @@ + #define PACKET_SETUP_DEV _IOW('X', 1, unsigned int) + #define PACKET_TEARDOWN_DEV _IOW('X', 2, unsigned int) + #endif ++#ifndef PACKET_CTRL_CMD ++#define PACKET_CTRL_CMD _IOWR('X', 1, struct pkt_ctrl_command) ++#endif ++ ++#define MAJOR(dev) ((dev & 0xfff00) >> 8) ++#define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00)) ++#define MKDEV(ma,mi) ((mi & 0xff) | (ma << 8) | ((mi & ~0xff) << 12)) ++ ++#define MISC_MAJOR 10 ++#define CTL_DIR "/dev/pktcdvd" ++#define CTL_DEV "control" ++ ++#define PKT_CTRL_CMD_SETUP 0 ++#define PKT_CTRL_CMD_TEARDOWN 1 ++#define PKT_CTRL_CMD_STATUS 2 ++ ++struct pkt_ctrl_command { ++ __u32 command; /* in: Setup, teardown, status */ ++ __u32 dev_index; /* in/out: Device index */ ++ __u32 dev; /* in/out: Device nr for cdrw device */ ++ __u32 pkt_dev; /* out: Device nr for packet device */ ++ __u32 num_devices; /* out: Largest device index + 1 */ ++ __u32 padding; ++}; ++ + +-int init_cdrom(int fd) ++static int init_cdrom(int fd) + { + if (ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) < 0) { + perror("drive not ready\n"); +@@ -54,7 +81,7 @@ int init_cdrom(int fd) + return 0; + } + +-void setup_dev(char *pkt_device, char *device, int rem) ++static void setup_dev(char *pkt_device, char *device, int rem) + { + int pkt_fd, dev_fd, cmd; + +@@ -88,29 +115,233 @@ void setup_dev(char *pkt_device, char *d + close(pkt_fd); + } + +-int usage(void) ++static int usage(void) + { +- printf("pktsetup /dev/pktcdvd0 /dev/cdrom\tsetup device\n"); +- printf("pktsetup -d /dev/pktcdvd0\t\ttear down device\n"); ++ printf("For pktcdvd < 0.2.0:\n"); ++ printf(" pktsetup /dev/pktcdvd0 /dev/cdrom setup device\n"); ++ printf(" pktsetup -d /dev/pktcdvd0 tear down device\n"); ++ printf("For pktcdvd >= 0.2.0:\n"); ++ printf(" pktsetup dev_name /dev/cdrom setup device\n"); ++ printf(" pktsetup -d dev_name tear down device\n"); ++ printf(" pktsetup -d major:minor tear down device\n"); ++ printf(" pktsetup -s show device mappings\n"); + return 1; + } + ++/* ++ * Find the minor device number for the pktcdvd control device. ++ */ ++static int get_misc_minor(void) ++{ ++ int minor; ++ char name[64]; ++ FILE *f; ++ ++ if ((f = fopen("/proc/misc", "r")) == NULL) ++ return -1; ++ while (fscanf(f, " %d %64s", &minor, name) == 2) { ++ if (strcmp(name, "pktcdvd") == 0) { ++ fclose(f); ++ return minor; ++ } ++ } ++ fclose(f); ++ return -1; ++} ++ ++static const char *pkt_dev_name(const char *dev) ++{ ++ static char buf[128]; ++ snprintf(buf, sizeof(buf), "%s/%s", CTL_DIR, dev); ++ return buf; ++} ++ ++static void create_ctl_dev(void) ++{ ++ int misc_minor; ++ struct stat stat_buf; ++ int dev; ++ ++ if ((misc_minor = get_misc_minor()) < 0) { ++ system("/sbin/modprobe pktcdvd"); ++ misc_minor = get_misc_minor(); ++ } ++ if (misc_minor < 0) { ++ fprintf(stderr, "Can't find pktcdvd character device\n"); ++ return; ++ } ++ dev = MKDEV(MISC_MAJOR, misc_minor); ++ ++ if ((stat(pkt_dev_name(CTL_DEV), &stat_buf) >= 0) && ++ S_ISCHR(stat_buf.st_mode) && (stat_buf.st_rdev == dev)) ++ return; /* Already set up */ ++ ++ mkdir(CTL_DIR, 0755); ++ unlink(pkt_dev_name(CTL_DEV)); ++ mknod(pkt_dev_name(CTL_DEV), S_IFCHR | 0644, dev); ++} ++ ++static int remove_stale_dev_node(int ctl_fd, char *devname) ++{ ++ struct stat stat_buf; ++ int i, dev; ++ struct pkt_ctrl_command c; ++ ++ if (stat(pkt_dev_name(devname), &stat_buf) < 0) ++ return 0; ++ if (!S_ISBLK(stat_buf.st_mode)) ++ return 1; ++ dev = stat_buf.st_rdev; ++ memset(&c, 0, sizeof(struct pkt_ctrl_command)); ++ for (i = 0; ; i++) { ++ c.command = PKT_CTRL_CMD_STATUS; ++ c.dev_index = i; ++ if (ioctl(ctl_fd, PACKET_CTRL_CMD, &c) < 0) { ++ perror("ioctl"); ++ return 1; ++ } ++ if (i >= c.num_devices) ++ break; ++ if (c.pkt_dev == dev) ++ return 1; /* busy */ ++ } ++ unlink(pkt_dev_name(devname)); ++ return 0; ++} ++ ++static void setup_dev_chardev(char *pkt_device, char *device, int rem) ++{ ++ struct pkt_ctrl_command c; ++ struct stat stat_buf; ++ int ctl_fd, dev_fd; ++ ++ memset(&c, 0, sizeof(struct pkt_ctrl_command)); ++ ++ create_ctl_dev(); ++ if ((ctl_fd = open(pkt_dev_name(CTL_DEV), O_RDONLY)) < 0) { ++ perror("ctl open"); ++ return; ++ } ++ ++ if (!rem) { ++ if ((dev_fd = open(device, O_RDONLY | O_NONBLOCK)) == -1) { ++ perror("open cd-rom"); ++ goto out_close; ++ } ++ if (init_cdrom(dev_fd)) { ++ close(dev_fd); ++ goto out_close; ++ } ++ close(dev_fd); ++ ++ if (stat(device, &stat_buf) < 0) { ++ perror("stat cd-rom"); ++ goto out_close; ++ } ++ if (!S_ISBLK(stat_buf.st_mode)) { ++ fprintf(stderr, "Not a block device\n"); ++ goto out_close; ++ } ++ c.command = PKT_CTRL_CMD_SETUP; ++ c.dev = stat_buf.st_rdev; ++ ++ if (remove_stale_dev_node(ctl_fd, pkt_device) != 0) { ++ fprintf(stderr, "Device node '%s' already in use\n", pkt_device); ++ goto out_close; ++ } ++ if (ioctl(ctl_fd, PACKET_CTRL_CMD, &c) < 0) { ++ perror("ioctl"); ++ goto out_close; ++ } ++ mknod(pkt_dev_name(pkt_device), S_IFBLK | 0640, c.pkt_dev); ++ } else { ++ int major, minor, remove_node; ++ ++ if ((stat(pkt_dev_name(pkt_device), &stat_buf) >= 0) && ++ S_ISBLK(stat_buf.st_mode)) { ++ major = MAJOR(stat_buf.st_rdev); ++ minor = MINOR(stat_buf.st_rdev); ++ remove_node = 1; ++ } else if (sscanf(pkt_device, "%d:%d", &major, &minor) == 2) { ++ remove_node = 0; ++ } else { ++ fprintf(stderr, "Can't find major/minor numbers\n"); ++ goto out_close; ++ } ++ ++ c.command = PKT_CTRL_CMD_TEARDOWN; ++ c.pkt_dev = MKDEV(major, minor); ++ if (ioctl(ctl_fd, PACKET_CTRL_CMD, &c) < 0) { ++ perror("ioctl"); ++ goto out_close; ++ } ++ if (remove_node) ++ unlink(pkt_dev_name(pkt_device)); ++ } ++ ++out_close: ++ close(ctl_fd); ++} ++ ++static void show_mappings(void) ++{ ++ struct pkt_ctrl_command c; ++ int ctl_fd, i; ++ ++ memset(&c, 0, sizeof(struct pkt_ctrl_command)); ++ ++ create_ctl_dev(); ++ if ((ctl_fd = open(pkt_dev_name(CTL_DEV), O_RDONLY)) < 0) { ++ perror("ctl open"); ++ return; ++ } ++ ++ for (i = 0; ; i++) { ++ c.command = PKT_CTRL_CMD_STATUS; ++ c.dev_index = i; ++ if (ioctl(ctl_fd, PACKET_CTRL_CMD, &c) < 0) { ++ perror("ioctl"); ++ goto out_close; ++ } ++ if (i >= c.num_devices) ++ break; ++ if (c.dev) { ++ printf("%2d : %d:%d -> %d:%d\n", ++ i, MAJOR(c.pkt_dev), MINOR(c.pkt_dev), ++ MAJOR(c.dev), MINOR(c.dev)); ++ } ++ } ++ ++out_close: ++ close(ctl_fd); ++} ++ + int main(int argc, char **argv) + { + int rem = 0, c; ++ char *pkt_device; ++ char *device; + + if (argc == 1) + return usage(); + +- while ((c = getopt(argc, argv, "d")) != EOF) { ++ while ((c = getopt(argc, argv, "ds?")) != EOF) { + switch (c) { + case 'd': + rem = 1; + break; ++ case 's': ++ show_mappings(); ++ return 0; + default: + return usage(); + } + } +- setup_dev(argv[optind], argv[optind + 1], rem); ++ pkt_device = argv[optind]; ++ device = argv[optind + 1]; ++ if (strchr(pkt_device, '/')) ++ setup_dev(pkt_device, device, rem); ++ else ++ setup_dev_chardev(pkt_device, device, rem); + return 0; + } +_ + +-- +Peter Osterlund - petero2@telia.com +http://w1.894.telia.com/~u89404340 diff --git a/udftools-1.0.0b3-wrudf-gcc4.patch b/udftools-1.0.0b3-wrudf-gcc4.patch new file mode 100644 index 0000000..1369012 --- /dev/null +++ b/udftools-1.0.0b3-wrudf-gcc4.patch @@ -0,0 +1,53 @@ +Subject: Bug#288621: udftools: FTBFS (amd64/gcc-4.0): invalid lvalue in assignment +From: Andreas Jochens +Message-Id: +Date: Tue, 04 Jan 2005 19:29:01 +0100 +Lines: 59 + +Package: udftools +Severity: normal +Tags: patch + +When building 'udftools' on amd64 with gcc-4.0, +I get the following error: + +wrudf.c:119: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness +wrudf.c:119: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness +wrudf.c:119: warning: pointer targets in passing argument 1 of 'strcmp' differ in signedness +wrudf.c:119: warning: pointer targets in passing argument 1 of 'strncmp' differ in signedness +wrudf.c:230: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness +wrudf.c:230: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness +wrudf.c:230: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness +wrudf.c:230: warning: pointer targets in passing argument 1 of 'strcmp' differ in signedness +wrudf.c:230: warning: pointer targets in passing argument 1 of 'strncmp' differ in signedness +wrudf.c:245: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness +wrudf.c:245: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness +wrudf.c:245: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness +wrudf.c:245: warning: pointer targets in passing argument 1 of 'strcmp' differ in signedness +wrudf.c:245: warning: pointer targets in passing argument 1 of 'strncmp' differ in signedness +wrudf.c:248: error: invalid lvalue in assignment +make[2]: *** [wrudf.o] Error 1 +make[2]: Leaving directory `/udftools-1.0.0b3/wrudf' + +With the attached patch 'udftools' can be compiled +on amd64 using gcc-4.0. + +The patch also changes the Build-Depends from 'libreadline4-dev' +to 'libreadline5-dev'. + +Regards +Andreas Jochens + +diff -urN ../tmp-orig/udftools-1.0.0b3/wrudf/wrudf.c ./wrudf/wrudf.c +--- ../tmp-orig/udftools-1.0.0b3/wrudf/wrudf.c 2002-11-26 08:18:51.000000000 +0100 ++++ ./wrudf/wrudf.c 2005-01-04 16:56:49.394078200 +0100 +@@ -245,7 +245,7 @@ + } else if( strncmp( spm->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL)) == 0 ) + virtualPartitionNum = i; + } +- (char*)spm += spm->partitionMapLength; ++ spm = (char*)spm + spm->partitionMapLength; + } + + if( medium == CDR ) { +diff -urN ../tmp-orig/udftools-1.0.0b3/debian/control ./debian/control diff --git a/udftools-1.0.0b3.patch b/udftools-1.0.0b3.patch deleted file mode 100644 index 5ef0825..0000000 --- a/udftools-1.0.0b3.patch +++ /dev/null @@ -1,346 +0,0 @@ -From: Peter Osterlund -Subject: Re: [RFC][PATCH] Control pktcdvd with an auxiliary character device -To: linux-kernel@vger.kernel.org -Cc: Christoph Hellwig , Arnd Bergmann , - Jens Axboe , Andrew Morton -Date: Wed Jul 14 02:17:27 2004 +0200 - -Peter Osterlund writes: - -> Peter Osterlund writes: -> -> > Christoph Hellwig writes: -> > -> > > On Sun, Jul 11, 2004 at 01:20:45AM +0200, Arnd Bergmann wrote: -> > > > These are actually incorrect definitions since the ioctl argument is -> > > > not a pointer to unsigned int but instead just an int. However, that's -> > > > too late to fix without breaking the existing tools. -> > > -> > > The tools need to change anyway to get away from the broken behaviour to -> > > issue in ioctl on the actual block device to bind it.. -> > -> > OK, I'll create a patch that gets rid of the ioctl interface and uses -> > an auxiliary character device instead to control device bindings. -> -> Here is a patch for 2.6.7-mm7 that does that. The driver creates a -> misc character device and bind/unbind of the block devices are -> controlled by ioctl commands on the char device. -> -> This patch needs corresponding changes in the pktsetup user space -> program. I'll post a patch for pktsetup as a separate message. - -And here is a patch for udftools-1.0.0b3 that updates the pktsetup -program to make it able to use the character device for block device -setup/teardown. - ---- - - udftools-1.0.0b3-petero/pktsetup/pktsetup.c | 245 +++++++++++++++++++++++++++- - 1 files changed, 238 insertions(+), 7 deletions(-) - -diff -puN pktsetup/pktsetup.c~pktsetup-char-dev pktsetup/pktsetup.c ---- udftools-1.0.0b3/pktsetup/pktsetup.c~pktsetup-char-dev 2004-07-12 19:57:51.000000000 +0200 -+++ udftools-1.0.0b3-petero/pktsetup/pktsetup.c 2004-07-14 00:34:02.471317888 +0200 -@@ -1,5 +1,6 @@ - /* - * Copyright (c) 1999,2000 Jens Axboe -+ * Copyright (c) 2004 Peter Osterlund - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by -@@ -19,6 +20,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -33,8 +35,33 @@ - #define PACKET_SETUP_DEV _IOW('X', 1, unsigned int) - #define PACKET_TEARDOWN_DEV _IOW('X', 2, unsigned int) - #endif -+#ifndef PACKET_CTRL_CMD -+#define PACKET_CTRL_CMD _IOWR('X', 1, struct pkt_ctrl_command) -+#endif -+ -+#define MAJOR(dev) ((dev & 0xfff00) >> 8) -+#define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00)) -+#define MKDEV(ma,mi) ((mi & 0xff) | (ma << 8) | ((mi & ~0xff) << 12)) -+ -+#define MISC_MAJOR 10 -+#define CTL_DIR "/dev/pktcdvd" -+#define CTL_DEV "control" -+ -+#define PKT_CTRL_CMD_SETUP 0 -+#define PKT_CTRL_CMD_TEARDOWN 1 -+#define PKT_CTRL_CMD_STATUS 2 -+ -+struct pkt_ctrl_command { -+ __u32 command; /* in: Setup, teardown, status */ -+ __u32 dev_index; /* in/out: Device index */ -+ __u32 dev; /* in/out: Device nr for cdrw device */ -+ __u32 pkt_dev; /* out: Device nr for packet device */ -+ __u32 num_devices; /* out: Largest device index + 1 */ -+ __u32 padding; -+}; -+ - --int init_cdrom(int fd) -+static int init_cdrom(int fd) - { - if (ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) < 0) { - perror("drive not ready\n"); -@@ -54,7 +81,7 @@ int init_cdrom(int fd) - return 0; - } - --void setup_dev(char *pkt_device, char *device, int rem) -+static void setup_dev(char *pkt_device, char *device, int rem) - { - int pkt_fd, dev_fd, cmd; - -@@ -88,29 +115,233 @@ void setup_dev(char *pkt_device, char *d - close(pkt_fd); - } - --int usage(void) -+static int usage(void) - { -- printf("pktsetup /dev/pktcdvd0 /dev/cdrom\tsetup device\n"); -- printf("pktsetup -d /dev/pktcdvd0\t\ttear down device\n"); -+ printf("For pktcdvd < 0.2.0:\n"); -+ printf(" pktsetup /dev/pktcdvd0 /dev/cdrom setup device\n"); -+ printf(" pktsetup -d /dev/pktcdvd0 tear down device\n"); -+ printf("For pktcdvd >= 0.2.0:\n"); -+ printf(" pktsetup dev_name /dev/cdrom setup device\n"); -+ printf(" pktsetup -d dev_name tear down device\n"); -+ printf(" pktsetup -d major:minor tear down device\n"); -+ printf(" pktsetup -s show device mappings\n"); - return 1; - } - -+/* -+ * Find the minor device number for the pktcdvd control device. -+ */ -+static int get_misc_minor(void) -+{ -+ int minor; -+ char name[64]; -+ FILE *f; -+ -+ if ((f = fopen("/proc/misc", "r")) == NULL) -+ return -1; -+ while (fscanf(f, " %d %64s", &minor, name) == 2) { -+ if (strcmp(name, "pktcdvd") == 0) { -+ fclose(f); -+ return minor; -+ } -+ } -+ fclose(f); -+ return -1; -+} -+ -+static const char *pkt_dev_name(const char *dev) -+{ -+ static char buf[128]; -+ snprintf(buf, sizeof(buf), "%s/%s", CTL_DIR, dev); -+ return buf; -+} -+ -+static void create_ctl_dev(void) -+{ -+ int misc_minor; -+ struct stat stat_buf; -+ int dev; -+ -+ if ((misc_minor = get_misc_minor()) < 0) { -+ system("/sbin/modprobe pktcdvd"); -+ misc_minor = get_misc_minor(); -+ } -+ if (misc_minor < 0) { -+ fprintf(stderr, "Can't find pktcdvd character device\n"); -+ return; -+ } -+ dev = MKDEV(MISC_MAJOR, misc_minor); -+ -+ if ((stat(pkt_dev_name(CTL_DEV), &stat_buf) >= 0) && -+ S_ISCHR(stat_buf.st_mode) && (stat_buf.st_rdev == dev)) -+ return; /* Already set up */ -+ -+ mkdir(CTL_DIR, 0755); -+ unlink(pkt_dev_name(CTL_DEV)); -+ mknod(pkt_dev_name(CTL_DEV), S_IFCHR | 0644, dev); -+} -+ -+static int remove_stale_dev_node(int ctl_fd, char *devname) -+{ -+ struct stat stat_buf; -+ int i, dev; -+ struct pkt_ctrl_command c; -+ -+ if (stat(pkt_dev_name(devname), &stat_buf) < 0) -+ return 0; -+ if (!S_ISBLK(stat_buf.st_mode)) -+ return 1; -+ dev = stat_buf.st_rdev; -+ memset(&c, 0, sizeof(struct pkt_ctrl_command)); -+ for (i = 0; ; i++) { -+ c.command = PKT_CTRL_CMD_STATUS; -+ c.dev_index = i; -+ if (ioctl(ctl_fd, PACKET_CTRL_CMD, &c) < 0) { -+ perror("ioctl"); -+ return 1; -+ } -+ if (i >= c.num_devices) -+ break; -+ if (c.pkt_dev == dev) -+ return 1; /* busy */ -+ } -+ unlink(pkt_dev_name(devname)); -+ return 0; -+} -+ -+static void setup_dev_chardev(char *pkt_device, char *device, int rem) -+{ -+ struct pkt_ctrl_command c; -+ struct stat stat_buf; -+ int ctl_fd, dev_fd; -+ -+ memset(&c, 0, sizeof(struct pkt_ctrl_command)); -+ -+ create_ctl_dev(); -+ if ((ctl_fd = open(pkt_dev_name(CTL_DEV), O_RDONLY)) < 0) { -+ perror("ctl open"); -+ return; -+ } -+ -+ if (!rem) { -+ if ((dev_fd = open(device, O_RDONLY | O_NONBLOCK)) == -1) { -+ perror("open cd-rom"); -+ goto out_close; -+ } -+ if (init_cdrom(dev_fd)) { -+ close(dev_fd); -+ goto out_close; -+ } -+ close(dev_fd); -+ -+ if (stat(device, &stat_buf) < 0) { -+ perror("stat cd-rom"); -+ goto out_close; -+ } -+ if (!S_ISBLK(stat_buf.st_mode)) { -+ fprintf(stderr, "Not a block device\n"); -+ goto out_close; -+ } -+ c.command = PKT_CTRL_CMD_SETUP; -+ c.dev = stat_buf.st_rdev; -+ -+ if (remove_stale_dev_node(ctl_fd, pkt_device) != 0) { -+ fprintf(stderr, "Device node '%s' already in use\n", pkt_device); -+ goto out_close; -+ } -+ if (ioctl(ctl_fd, PACKET_CTRL_CMD, &c) < 0) { -+ perror("ioctl"); -+ goto out_close; -+ } -+ mknod(pkt_dev_name(pkt_device), S_IFBLK | 0640, c.pkt_dev); -+ } else { -+ int major, minor, remove_node; -+ -+ if ((stat(pkt_dev_name(pkt_device), &stat_buf) >= 0) && -+ S_ISBLK(stat_buf.st_mode)) { -+ major = MAJOR(stat_buf.st_rdev); -+ minor = MINOR(stat_buf.st_rdev); -+ remove_node = 1; -+ } else if (sscanf(pkt_device, "%d:%d", &major, &minor) == 2) { -+ remove_node = 0; -+ } else { -+ fprintf(stderr, "Can't find major/minor numbers\n"); -+ goto out_close; -+ } -+ -+ c.command = PKT_CTRL_CMD_TEARDOWN; -+ c.pkt_dev = MKDEV(major, minor); -+ if (ioctl(ctl_fd, PACKET_CTRL_CMD, &c) < 0) { -+ perror("ioctl"); -+ goto out_close; -+ } -+ if (remove_node) -+ unlink(pkt_dev_name(pkt_device)); -+ } -+ -+out_close: -+ close(ctl_fd); -+} -+ -+static void show_mappings(void) -+{ -+ struct pkt_ctrl_command c; -+ int ctl_fd, i; -+ -+ memset(&c, 0, sizeof(struct pkt_ctrl_command)); -+ -+ create_ctl_dev(); -+ if ((ctl_fd = open(pkt_dev_name(CTL_DEV), O_RDONLY)) < 0) { -+ perror("ctl open"); -+ return; -+ } -+ -+ for (i = 0; ; i++) { -+ c.command = PKT_CTRL_CMD_STATUS; -+ c.dev_index = i; -+ if (ioctl(ctl_fd, PACKET_CTRL_CMD, &c) < 0) { -+ perror("ioctl"); -+ goto out_close; -+ } -+ if (i >= c.num_devices) -+ break; -+ if (c.dev) { -+ printf("%2d : %d:%d -> %d:%d\n", -+ i, MAJOR(c.pkt_dev), MINOR(c.pkt_dev), -+ MAJOR(c.dev), MINOR(c.dev)); -+ } -+ } -+ -+out_close: -+ close(ctl_fd); -+} -+ - int main(int argc, char **argv) - { - int rem = 0, c; -+ char *pkt_device; -+ char *device; - - if (argc == 1) - return usage(); - -- while ((c = getopt(argc, argv, "d")) != EOF) { -+ while ((c = getopt(argc, argv, "ds?")) != EOF) { - switch (c) { - case 'd': - rem = 1; - break; -+ case 's': -+ show_mappings(); -+ return 0; - default: - return usage(); - } - } -- setup_dev(argv[optind], argv[optind + 1], rem); -+ pkt_device = argv[optind]; -+ device = argv[optind + 1]; -+ if (strchr(pkt_device, '/')) -+ setup_dev(pkt_device, device, rem); -+ else -+ setup_dev_chardev(pkt_device, device, rem); - return 0; - } -_ - --- -Peter Osterlund - petero2@telia.com -http://w1.894.telia.com/~u89404340 diff --git a/udftools.spec b/udftools.spec index 04d703b..87d3186 100644 --- a/udftools.spec +++ b/udftools.spec @@ -1,13 +1,14 @@ Summary: Linux UDF Filesystem userspace utilities Name: udftools Version: 1.0.0b3 -Release: 2 - +Release: 3 License: GPL Group: Applications/Archiving URL: http://sourceforge.net/projects/linux-udf/ Source: http://dl.sf.net/linux-udf/udftools-%{version}.tar.gz -Patch: udftools-1.0.0b3.patch +Patch0: udftools-1.0.0b3-pktsetup-chardev.patch +Patch1: udftools-1.0.0b3-mkudffs-bigendian.patch +Patch2: udftools-1.0.0b3-wrudf-gcc4.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: readline-devel @@ -17,7 +18,9 @@ Linux UDF Filesystem userspace utilities. %prep %setup -%patch -p1 +%patch0 -p1 -b .pktsetup-chardev +%patch1 -p1 -b .mkudffs-bigendian +%patch2 -p1 -b .wrudf-gcc4 %build @@ -44,8 +47,8 @@ Linux UDF Filesystem userspace utilities. %changelog -* Fri Apr 7 2005 Michael Schwendt -- rebuilt +* Tue May 3 2005 Matthias Saou 1.0.0b3-3 +- Include patches to fix big endian issue and gcc4 compile. * Mon Feb 7 2005 Matthias Saou 1.0.0b3-1 - Initial RPM release, based on spec file from John Treacy.