3 # Common functions for managing the CD burning profiles
5 BEGIN { push(@INC, ".."); };
8 %access = &get_module_acl();
9 &foreign_require("fdisk", "fdisk-lib.pl");
12 # Returns a list of all burn profiles available for use.
13 # Each profile can be for an ISO, a list of directory mappings, or a list of
18 opendir(DIR, $module_config_directory);
19 foreach $f (sort { $a cmp $b } readdir(DIR)) {
20 next if ($f !~ /^(\S+)\.burn$/);
21 push(@rv, &get_profile($1));
31 &read_file("$module_config_directory/$_[0].burn", \%burn);
33 $burn{'file'} = "$module_config_directory/$_[0].burn";
37 # save_profile(&profile)
40 $_[0]->{'id'} = time() if (!$_[0]->{'id'});
41 &write_file("$module_config_directory/$_[0]->{'id'}.burn", $_[0]);
44 # delete_profile(&profile)
47 unlink("$module_config_directory/$_[0]->{'id'}.burn");
50 # list_cdrecord_devices()
51 # Returns a list of all possible CD burner devices
52 sub list_cdrecord_devices
56 # First get from CDrecord
57 open(SCAN, "$config{'cdrecord'} $config{'extra'} -scanbus 2>/dev/null |");
59 if (/^\s+(\S+)\s+\d+\)\s+'(.*)'\s+'(.*)'\s+'(.*)'\s+(.*)/) {
60 push(@rv, { 'dev' => $1,
68 # Then add all cdrom devices
69 local $uname = `uname -r 2>&1`;
70 if ($uname =~ /^2\.(\d+)\./ && $1 >= 6) {
72 foreach $disk (&fdisk::list_disks_partitions(1)) {
73 if ($disk->{'media'} eq "cdrom" &&
74 !$done{$disk->{'device'}}) {
75 push(@rv, { 'dev' => $disk->{'device'},
76 'name' => $disk->{'model'},
77 'type' => uc($disk->{'media'}) });
85 @cdr_drivers = ( 'cdd2600', 'plextor', 'plextor-scan', 'generic-mmc',
86 'generic-mmc-raw', 'ricoh-mp6200', 'yamaha-cdr10x',
87 'teac-cdr55', 'sony-cdu920', 'sony-cdu948', 'taiyo-yuden',
90 # can_use_profile(&profile)
91 # Returns 1 if some burn profile can be used
94 return 1 if ($access{'profiles'} eq '*');
95 local %can = map { $_, 1 } split(/\s+/, $access{'profiles'});
96 return $can{$_[0]->{'id'}};
100 # Returns 1 if some file is in an allowed directory
103 local @dirs = split(/\s+/, $access{'dirs'});
104 return 1 if ($dirs[0] eq "/");
105 local $path = &resolve_links($_[0]);
108 return 1 if (&is_under_directory(&resolve_links($d), $path));