Last change
on this file since 3714 was 3447, checked in by Bruno Cornec, 9 years ago |
- Adds a mr-device-mounted binary to MondoRescue (replaces the code of the C function is_this_device_mounted) and the corresponding perl function (mr_device_mounted) to handle cases where a mounted device has a different name than the one seen on mount (e.g. /dev/rhel/root and /dev/mapper/rhel-root)
- Adds perl function mr_file_copy_and_erase_hash to empty the hash generated in mr_file_read_all_link and thus avoid filling the hash it generates, which is useful for a recursive function, but not when called multiple times from another perl script. To be improved later on.
- Adapt build procedure to the new binary (tested on Mageia 5 and RHEL7)
|
-
Property svn:executable
set to
*
|
File size:
1.6 KB
|
Line | |
---|
1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # $Id$
|
---|
4 | # Copyright B. Cornec 2005-2015
|
---|
5 | # Provided under the GPL v2
|
---|
6 | #
|
---|
7 | # Test mr_device_mounted to know if a device is mounted
|
---|
8 | #
|
---|
9 | use strict;
|
---|
10 | use Data::Dumper;
|
---|
11 | # For pbdebug
|
---|
12 | use ProjectBuilder::Base;
|
---|
13 | use MondoRescue::Disk;
|
---|
14 |
|
---|
15 | =pod
|
---|
16 |
|
---|
17 | =head1 NAME
|
---|
18 |
|
---|
19 | mr-device-mounted query whether a device is mounted or not
|
---|
20 |
|
---|
21 | =head1 DESCRIPTION
|
---|
22 |
|
---|
23 | mr-device-mounted query whether a device is mounted or not
|
---|
24 |
|
---|
25 | =head1 SYNOPSIS
|
---|
26 |
|
---|
27 | mr-device-mounted /path/to/device
|
---|
28 |
|
---|
29 | =head1 ARGUMENTS
|
---|
30 |
|
---|
31 | =over 4
|
---|
32 |
|
---|
33 | =item B</path/to/device>
|
---|
34 |
|
---|
35 | This is the path of the device name to query
|
---|
36 |
|
---|
37 | =back
|
---|
38 |
|
---|
39 | =head1 WEB SITES
|
---|
40 |
|
---|
41 | The main Web site of the project is available at L<http://www.mondorescue.org>. Bug reports should be filled using the trac instance of the project at L<http://trac.mondorescue.org/>.
|
---|
42 |
|
---|
43 | =head1 USER MAILING LIST
|
---|
44 |
|
---|
45 | For community exchanges around MondoRescue please use the list L<http://sourceforge.net/mailarchive/forum.php?forum_name=mondo-devel>
|
---|
46 |
|
---|
47 | =head1 AUTHORS
|
---|
48 |
|
---|
49 | The MondoRescue team lead by Bruno Cornec L<mailto:bruno@mondorescue.org>.
|
---|
50 |
|
---|
51 | =head1 COPYRIGHT
|
---|
52 |
|
---|
53 | MondoRescue is distributed under the GPL v2.0 license or later,
|
---|
54 | described in the file C<COPYING> included with the distribution.
|
---|
55 |
|
---|
56 | =cut
|
---|
57 |
|
---|
58 | if ((defined $ARGV[0]) && ($ARGV[0] eq "-v")) {
|
---|
59 | shift;
|
---|
60 | $pbdebug = 2;
|
---|
61 | }
|
---|
62 |
|
---|
63 | my $txt = "";
|
---|
64 | my $txt2 = "";
|
---|
65 | my $ans = "";
|
---|
66 |
|
---|
67 | if (defined $ARGV[0]) {
|
---|
68 | foreach my $i (@ARGV) {
|
---|
69 | $ans = mr_device_mounted($i);
|
---|
70 | $txt = " not" if (not defined $ans);
|
---|
71 | $txt2 = " on $ans" if (defined $ans);
|
---|
72 | pb_log(0, "Device $i is$txt mounted$txt2\n");
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | # In case we gave only one param (MondoRescue) then return 0 for success, 1 otherwise
|
---|
77 | if (not defined $ARGV[1]) {
|
---|
78 | exit(0) if (defined $ans);
|
---|
79 | exit(1);
|
---|
80 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.