forked from tmavr/btrfsman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
btrfsman_label.cgi
80 lines (61 loc) · 1.97 KB
/
btrfsman_label.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl
# btrfsman_label.cgi
# BTRFS Manager - Label Devices
require './btrfsman-lib.pl';
&ReadParse();
ui_print_header(undef, $text{'label_title'}, "", undef, 1, 1);
if($in){
print $text{'txt_arg'}, $in, $text{'txt_p'};
}
$act = $in{'act'};
$mountpoint = $in{'mountpoint'};
$newlabel = $in{'newlabel'};
if ((length $newlabel) > 255){
print "label too long";
}
if ($newlabel =~ /[ %&<>!\x27\x60\x3B\x3A\x\n\r\l]/) {
print "not a safe string to use as label";
}
if (($act eq 'label') && ($mountpoint) ) {
if ($newlabel) {
$cmd = "btrfs fi label $mountpoint $newlabel 2>&1";
print $text{txt_executing}, $cmd, $text{'txt_p'};
$result=`$cmd`;
print $result, $text{'txt_p'};
print $text{'label_changed'}, $text{'txt_p'} ;
}
}
else{
print $text{'index_btrfslogical'};
show_fs();
label_menu();
}
ui_print_footer('/', 'Webmin index', '', 'Module menu');
=head1 label_menu
Display label menu
=cut
sub label_menu {
print $text{'label_mounted_h'};
$result = `mount |grep btrfs`;
$result =~ s/\n/<br>/g;
@splitres = split /<br>/, $result;
print $text{'index_youhave1'}, scalar (@splitres), $text{'index_youhave3'};
$did=0;
for (@splitres){
print ui_columns_start([ @splitres[$did], ""]);
$drivea = @splitres[$did];
@driveb = split /on /, $drivea;
@drivec = split / /, @driveb[1];
@mountedrive[$did] = @drivec[0];
print ui_columns_row([$text{'index_mountp'}, @mountedrive[$did]]) ;
if ($result =~ /no stats available/) {
print ui_columns_row([$text{'index_warn'}, $text{'index_warnnoscrub'}]);
}
print ui_columns_end();
print ui_buttons_start();
print ui_buttons_row("btrfsman_label.cgi", $text{'label_bt_change'}, $text{'label_bt_change_help'}, ui_hidden('act', 'label'), ui_hidden('mountpoint', @mountedrive[$did]), ui_textbox('newlabel','label'));
print ui_buttons_end();
print "<p><p>";
$did++;
}
}