This patch adds a new single parameter form to pktsetup. This new form takes only the name of the cdrom device to bind to, and will bind the next unused pktcdvd minor device to it, and print that device number to stdout. - Phillip Susi diff -ru udftools-1.0.0b3.orig/doc/pktsetup.8 udftools-1.0.0b3/doc/pktsetup.8 --- udftools-1.0.0b3.orig/doc/pktsetup.8 2006-01-08 18:08:04.000000000 -0500 +++ udftools-1.0.0b3/doc/pktsetup.8 2006-01-08 18:58:59.000000000 -0500 @@ -37,14 +37,32 @@ .B pktsetup .B \-d .I packet_device +.br +.B pktsetup +.I /dev/cdrom .ad b .SH DESCRIPTION -.B Pktsetup +.B \fBpktsetup\fP is used to associate packet devices with CD or DVD block devices, so that the packet device can then be mounted and potentially used as a read/write filesystem. This requires kernel support for the packet device, and the UDF filesystem. .PP +To old style to set up a device is: +.IP +\fBpktsetup \fI/dev/pktcdvd/pktcdvd0 /dev/cdrom\fP +.PP +This usage will create the devnode \fI/dev/pktcdvd/pktcdvd0\fP +and bind it to \fI/dev/cdrom\fP. +.PP +The new form is: +.IP +\fBpktsetup \fI/dev/cdrom\fP +.PP +This form will bind the next availible pkcdvd minor device to +\fI/dev/cdrom\fP and print the device number to stdout. No device +node will be created, that job is left up to udev. +.PP See /usr/share/doc/udftools/README.Debian for more information. .UE @@ -55,7 +73,9 @@ .SH OPTIONS .IP "\fB\-d \fIpacket-device\fP" Delete the association between the specified \fIpacket-device\fP -and its block device. +and its block device. The device may either be of the form +\fI/dev/pktcdvd/pktcdvd0\fP or \fI252:0\fP. + .SH EXAMPLE The following commands provide an example of using the @@ -74,7 +94,7 @@ .SH FILES .nf -/dev/pktcdvd0,/dev/pktcdvd1,... CD/DVD packet devices (block major=97) +/dev/pktcdvd0,/dev/pktcdvd1,... CD/DVD packet devices (block major=252) .fi .SH AUTHOR diff -ru udftools-1.0.0b3.orig/pktsetup/pktsetup.c udftools-1.0.0b3/pktsetup/pktsetup.c --- udftools-1.0.0b3.orig/pktsetup/pktsetup.c 2006-01-08 18:08:03.000000000 -0500 +++ udftools-1.0.0b3/pktsetup/pktsetup.c 2006-01-08 18:34:58.000000000 -0500 @@ -125,6 +125,8 @@ 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"); + printf("And in this version:\n"); + printf(" pktsetup /dev/cdrom setup device\n"); return 1; } @@ -245,7 +247,7 @@ c.command = PKT_CTRL_CMD_SETUP; c.dev = stat_buf.st_rdev; - if (remove_stale_dev_node(ctl_fd, pkt_device) != 0) { + if (pkt_device && remove_stale_dev_node(ctl_fd, pkt_device) != 0) { fprintf(stderr, "Device node '%s' already in use\n", pkt_device); goto out_close; } @@ -253,7 +255,10 @@ perror("ioctl"); goto out_close; } - mknod(pkt_dev_name(pkt_device), S_IFBLK | 0640, c.pkt_dev); + if( pkt_device ) + mknod(pkt_dev_name(pkt_device), S_IFBLK | 0640, c.pkt_dev); + else + printf("Assigned device number %d:%d\n", MAJOR(c.pkt_dev), MINOR(c.pkt_dev) ); } else { int major, minor, remove_node; @@ -322,9 +327,6 @@ char *pkt_device; char *device; - if (argc == 1) - return usage(); - while ((c = getopt(argc, argv, "ds?")) != EOF) { switch (c) { case 'd': @@ -337,11 +339,15 @@ return usage(); } } - 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; + if( argc == 2 ) + setup_dev_chardev(NULL, argv[1], 0 ); + else { + 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; + } }