Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aix-pm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
aix-pm
Commits
a2dd2625
Commit
a2dd2625
authored
5 years ago
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
remove more special fileystems
parent
e6d3f1b0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/util/Util/Filesystems.pm
+121
-78
121 additions, 78 deletions
modules/util/Util/Filesystems.pm
with
121 additions
and
78 deletions
modules/util/Util/Filesystems.pm
+
121
−
78
View file @
a2dd2625
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
=head1 DESCRIPTION
=head1 DESCRIPTION
Wrapper for Linux::Proc::Filesystems and possibly other modules to obtain a full picture about an OS
Wrapper for Linux::Proc::Filesystems and possibly other modules to obtain
a full picture about available filesystems
Wanted information
Wanted information
* mount point info (Sys::Filesystem)
* mount point info (Sys::Filesystem)
...
@@ -26,26 +27,44 @@ my $initialzed= 0;
...
@@ -26,26 +27,44 @@ my $initialzed= 0;
my
$have_LPM
=
0
;
my
$have_LPM
=
0
;
BEGIN
{
BEGIN
{
eval
{
eval
{
require
Linux::Proc::
Mounts
;
require
Linux::Proc::
Mounts
;
};
};
if
(
$@
)
if
(
$@
)
{
{
print
"
consider to install Linux::Proc::Mounts
\n
";
#
print "consider to install Linux::Proc::Mounts\n";
}
}
else
else
{
{
$have_LPM
=
1
;
$have_LPM
=
1
;
}
}
}
}
my
%setable
=
map
{
$_
=>
1
}
qw()
;
my
%setable
=
map
{
$_
=>
1
}
qw()
;
my
%ignore_fs_type
=
map
{
$_
=>
1
}
qw(none rootfs tmpfs proc devpts devtmpfs usbfs sysfs binfmt_misc fusectl debugfs)
;
my
%ignore_fs_type
=
map
{
$_
=>
1
}
qw(none rootfs tmpfs proc devpts
devtmpfs usbfs sysfs binfmt_misc fusectl debugfs securityfs pstore
cgroup autofs hugetlbfs mqueue tracefs overlayfs fuse.gvfsd-fuse fuseblk
fuse.sshfs cifs squashfs nsfs
)
;
my
%ignore_fs_path
=
map
{
$_
=>
1
}
qw(tmpfs)
;
my
%ignore_fs_path
=
map
{
$_
=>
1
}
qw(tmpfs)
;
# print "ignore_fs_type: ", Dumper (\%ignore_fs_type);
# print "ignore_fs_type: ", Dumper (\%ignore_fs_type);
__PACKAGE__
->
main
()
unless
caller
();
sub
main
{
# print join (' ', __FILE__, __LINE__, 'main: caller=['. caller(). ']'), "\n";
my
$fs
=
new
Util::
Filesystems
;
$fs
->
_init
();
# print __LINE__, ' fs: ', Dumper($fs);
print
"
regular filesystems:
",
join
('
',
$fs
->
regular_filesystems
()),
"
\n
";
}
sub
new
sub
new
{
{
my
$class
=
shift
;
my
$class
=
shift
;
...
@@ -86,7 +105,7 @@ sub _init
...
@@ -86,7 +105,7 @@ sub _init
if
(
$have_LPM
)
if
(
$have_LPM
)
{
{
$m
=
Linux::Proc::
Mounts
->
read
;
$m
=
Linux::Proc::
Mounts
->
read
;
# print "m: ",
main::
Dumper ($m);
# print "m: ", Dumper ($m);
}
}
my
%fs
;
$self
->
{'
fs
'}
=
\
%fs
;
my
%fs
;
$self
->
{'
fs
'}
=
\
%fs
;
...
@@ -96,79 +115,87 @@ sub _init
...
@@ -96,79 +115,87 @@ sub _init
if
(
defined
(
$m
))
if
(
defined
(
$m
))
{
{
FS:
foreach
my
$mp
(
@$m
)
FS:
foreach
my
$mp
(
@$m
)
{
my
(
$fs_spec
,
$fs_type
)
=
(
$mp
->
spec
(),
$mp
->
fstype
());
# print "fs_spec=[$fs_spec] fs_type=[$fs_type] mp: ", main::Dumper ($mp);
if
(
exists
(
$ignore_fs_type
{
$fs_type
}))
{
# print "ignoring [$fs_type] ", Dumper ($mp);
next
FS
;
}
else
{
{
my
(
$fs_
file
,
$opts
)
=
(
$mp
->
file
(),
$mp
->
opts_hash
());
my
(
$fs_
spec
,
$fs_type
)
=
(
$mp
->
spec
(),
$mp
->
fstype
());
# print
__LINE__, " XXX: fs_file=[$fs_file]
fs_spec=[$fs_spec] fs_type=$fs_type
\n"
;
# print
"
fs_spec=[$fs_spec] fs_type=
[
$fs_type
] mp: ", Dumper ($mp)
;
my
$x
=
$fs
{
$fs_file
}
=
$dev
{
$fs_spec
}
=
if
(
exists
(
$ignore_fs_type
{
$fs_type
}))
{
{
'
mp
'
=>
$fs_file
,
# print __LINE__, " ignoring [$fs_type] ", Dumper ($mp);
'
spec
'
=>
$fs_spec
,
next
FS
;
'
type
'
=>
$fs_type
,
}
'
opts
'
=>
$opts
,
else
};
{
$x
->
{'
_mp
'}
=
$mp
if
(
$keep_mp_obj
);
my
(
$fs_file
,
$opts
)
=
(
$mp
->
file
(),
$mp
->
opts_hash
());
# $dev{$fs_spec}= $fs_file;
# print __LINE__, " XXX: fs_file=[$fs_file] fs_spec=[$fs_spec] fs_type=$fs_type\n";
$c_fst
{
$fs_type
}
++
;
my
$x
=
$fs
{
$fs_file
}
=
$count
++
;
$dev
{
$fs_spec
}
=
{
'
mp
'
=>
$fs_file
,
'
spec
'
=>
$fs_spec
,
'
type
'
=>
$fs_type
,
'
opts
'
=>
$opts
,
};
$x
->
{'
_mp
'}
=
$mp
if
(
$keep_mp_obj
);
# $dev{$fs_spec}= $fs_file;
$c_fst
{
$fs_type
}
++
;
$count
++
;
}
}
}
}
}
}
else
else
{
{
if
(
open
(
PM
,
'
/proc/mounts
'))
if
(
open
(
PM
,
'
/proc/mounts
'))
{
# print "reading /proc/mounts\n";
FS2:
while
(
<
PM
>
)
{
chop
;
# print ">>> [$_]\n";
my
(
$fs_spec
,
$fs_file
,
$fs_type
,
$fs_opts
,
$l1
,
$l2
)
=
split
('
',
$_
,
6
);
if
(
exists
(
$ignore_fs_type
{
$fs_type
}))
{
# print "ignoring [$fs_type] ", Dumper ($mp);
next
FS2
;
}
else
{
{
my
@opts
=
split
('
,
',
$fs_opts
);
# print "reading /proc/mounts\n";
# print "opts: [", join (';', @opts), "]\n";
FS2:
while
(
<
PM
>
)
my
%opts
;
foreach
my
$opt
(
@opts
)
{
{
# print "opt=[$opt]\n";
chop
;
my
(
$an
,
$av
)
=
split
('
=
',
$opt
,
2
);
# print ">>> [$_]\n";
$av
=
1
unless
(
defined
(
$av
));
my
(
$fs_spec
,
$fs_file
,
$fs_type
,
$fs_opts
,
$l1
,
$l2
)
=
split
('
',
$_
,
6
);
$opts
{
$an
}
=
$av
;
if
(
exists
(
$ignore_fs_type
{
$fs_type
})
||
$fs_type
=~
m#fuse\..*\.AppImage$#
# NOTE: is this pattern defined somewhere?
)
{
# print __LINE__, " ignoring [$fs_type] [$_]\n";
next
FS2
;
}
elsif
(
$fs_file
=~
m#^/var/lib/schroot/#
)
{
# print __LINE__, " ignoring schroot [$_]\n";
next
FS2
;
}
else
{
# print __LINE__, " using [$fs_type] [$_]\n";
my
@opts
=
split
('
,
',
$fs_opts
);
# print "opts: [", join (';', @opts), "]\n";
my
%opts
;
foreach
my
$opt
(
@opts
)
{
# print "opt=[$opt]\n";
my
(
$an
,
$av
)
=
split
('
=
',
$opt
,
2
);
$av
=
1
unless
(
defined
(
$av
));
$opts
{
$an
}
=
$av
;
}
# print "opts: ", Dumper (\%opts);
my
$x
=
$fs
{
$fs_file
}
=
$dev
{
$fs_spec
}
=
{
'
mp
'
=>
$fs_file
,
'
spec
'
=>
$fs_spec
,
'
type
'
=>
$fs_type
,
'
opts
'
=>
\
%opts
,
};
$c_fst
{
$fs_type
}
++
;
$count
++
;
}
}
}
# print "opts: ", main::Dumper (\%opts);
close
(
PM
);
my
$x
=
$fs
{
$fs_file
}
=
$dev
{
$fs_spec
}
=
{
'
mp
'
=>
$fs_file
,
'
spec
'
=>
$fs_spec
,
'
type
'
=>
$fs_type
,
'
opts
'
=>
\
%opts
,
};
$c_fst
{
$fs_type
}
++
;
$count
++
;
}
}
}
close
(
PM
);
}
}
}
$self
->
{'
_init
'}
=
1
;
$self
->
{'
_init
'}
=
1
;
...
@@ -177,6 +204,17 @@ sub _init
...
@@ -177,6 +204,17 @@ sub _init
$count
;
$count
;
}
}
sub
regular_filesystems
{
my
$self
=
shift
;
$self
->
_init
(
0
)
unless
(
$self
->
{
_init
});
my
@regular_filesystems
=
sort
keys
%
{
$self
->
{
fs
}};
(
wantarray
)
?
@regular_filesystems
:
\
@regular_filesystems
;
}
sub
df
sub
df
{
{
my
$self
=
shift
;
my
$self
=
shift
;
...
@@ -226,7 +264,12 @@ sub df
...
@@ -226,7 +264,12 @@ sub df
}
}
1
;
1
;
__END__
__END__
=head1 OPTIONAL MODULES
=head2 Linux::Proc::Mounts
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment