move point to raise exception
[sunny256-utils.git] / isoname
blob5f97b22f1d3ea548c4513133ab54f79d228559fa
1 #!/usr/bin/env perl
3 use strict;
4 use warnings;
6 my $Device = "/dev/cdrom";
7 # !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
8 my $Legal = "!\"#\$&'()*+,-./0123456789:;=?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
10 defined($ARGV[0]) && ($Device = $ARGV[0]);
12 my $vol_name = iso_name($Device);
13 $vol_name =~ s/([\x00-\x20<>\/\x7F-\x9F])/sprintf("%%%02X", ord($1))/ge;
14 if (-e $vol_name) {
15 die("$vol_name finnes allerede."); # FIXME.
18 print("Volume: \"$vol_name\"\n");
20 system("mount /cdrom");
22 open(ToFP, ">$vol_name") || die("$vol_name: Can't create file: $!");
23 open(PipeFP, "find /cdrom -type f | sort |") || die("Åpning av pipe: $!");
24 while (<PipeFP>) {
25 s!^/cdrom(.*)!$1!;
26 print(ToFP $_);
28 close(ToFP);
29 close(PipeFP);
31 system("umount /cdrom");
33 sub iso_name {
34 my $Device = shift;
35 my $Volname = "";
36 open(DevFP, "<$Device") || die("$Device: Can't open device for read: $!");
37 seek(DevFP, 32808, 0) || die("$Device: Can't seek: $!");
38 my $bytes_read = read(DevFP, $Volname, 32);
39 ($bytes_read == 32) || warn("$Device: Only read $bytes_read byte(s) from device.");
40 return $Volname;
41 } # iso_name()