From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.2.5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to; bh=H3iy5UYIGebdHLg0ylPdX4QieKoIgSDIb6pWm2NdeFc=; b=Ovfaav+ro3N4XuxMwr+XAxQvc1mwA6cmPQnaPUKlua+zYiJ7u7WmlMN0RGel/NSkQW ot0Z7mFzsNeLalk32c0S9Ed1V18NIVP8BqTH88ocE4xQOeQLq+87cgeKJ96c/nSX7o34 QzFYEatXwbMH3vSJ9PAPC6qmUPhnmEGMjObfy4je4DS6eZlwvjRtLwqLtNegeXqfeTn/ iI7s5reflzA3VTZz+mMu00tw0nVOAoMGTIIVJGBHZUo3Iiu+Xs661INsKUqXOAUtFMat Q2h0IOGPg8Z6Du0JE7rRatpYFicONxSU7iEOy5f9+wg6wHfqB6woNuoxUm1W3WYwbfye /c6w== X-Received: by 10.112.74.200 with SMTP id w8mr6130162lbv.79.1406743905299; Wed, 30 Jul 2014 11:11:45 -0700 (PDT) Sender: Denis Smirnov Date: Wed, 30 Jul 2014 22:11:41 +0400 From: =?koi8-r?B?5MXOydMg883J0s7P1w==?= To: community@lists.altlinux.org Message-ID: <20140730181141.GA11396@mw.mithraen.ru> Mail-Followup-To: community@lists.altlinux.org References: <20140725012132.5a6a5835@sem-notebook> <1256811406243387@web28h.yandex.ru> <20140728234111.GB19913@mw.mithraen.ru> <3406861406630905@web13j.yandex.ru> <20140729161619.GB7385@mw.mithraen.ru> <719891406657587@web4h.yandex.ru> <20140729192028.GA2059@mw.mithraen.ru> <845131406663561@web16j.yandex.ru> <20140730005244.GB32238@mw.mithraen.ru> <1208071406690813@web8g.yandex.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="A6N2fC+uXW/VQSAv" Content-Disposition: inline In-Reply-To: <1208071406690813@web8g.yandex.ru> Subject: Re: [Comm] =?koi8-r?b?wdfUz83PztTJ0s/Xwc7JxSDCxdogREU=?= X-BeenThere: community@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Community general discussions List-Id: ALT Linux Community general discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2014 18:11:53 -0000 Archived-At: List-Archive: List-Post: --A6N2fC+uXW/VQSAv Content-Type: multipart/mixed; boundary="r5Pyd7+fXNt84Ff3" Content-Disposition: inline --r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 30, 2014 at 07:26:53AM +0400, Speccyfighter wrote: > =F7 =D0=D2=C9=CE=C3=C9=D0=C5 =CD=CF=C4=C5=CC=D8 =CE=C5 =D3=D4=CF=CC=D8 = =D7=C1=D6=CE=CF, =C5=D3=CC=C9 =C5=D3=D4=D8 =C9=C4=C5=CE=D4=C9=C6=C9=CB=C1= =C3=C9=D1 =D0=CF SIZE. > =E4=C1 =C9 LABEL =CE=C1 =CD=C5=D3=D4=C5. =F7 =D0=D2=C9=CE=C3=C9=D0=C5 =C4=C1. > =E4=D5=CD=C1=C5=D4=D3=D1 CD =CE=C5 =D3=D4=CF=CC=D8 =D7=C1=D6=CE=CF. =ED= =CF=D6=CE=CF =CF=C2=CF=CA=D4=C9=D3=D8 shell'=CF=D7=D9=CD =D3=CB=D2=C9=D0=D4= =CF=CD. =F0=C5=D2=CC=CF=D7=D9=CA =D3=CB=D2=C9=D0=D4=C9=CB =C4=CF=CC=D6=C5=CE =D3 cd= rom =D2=C1=C2=CF=D4=C1=D4=D8 =CB=CF=D2=D2=C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D5=D7=C1=D6=C5=CE=C9=C5=CD, =E4=C5=CE=C9=D3 http://mithraen.ru/ --r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=lmount #!/usr/bin/perl #============================================================================# # List all block devices that not exists in fstab # #============================================================================# # (C) Denis Smirnov # #============================================================================# use strict; use warnings qw(FATAL all); use Cwd 'abs_path'; use Text::Table; my %devices; # List all USB devices foreach ( glob("/dev/disk/by-id/usb-*") ) { $devices{ abs_path($_) } = 1; } # List all removable devices { my @devs = split( "\n", `/bin/lsblk -d -r -o RO,KNAME` ); foreach (@devs) { next unless /^1\s+(.+)$/; $devices{$1} = 1; } } # List all devices in /etc/pmount.allow if ( open my $fh, "<", "/etc/pmount.allow" ) { while (<$fh>) { s/#.*//; s/\s+$//; next if $_ eq ''; $_ = abs_path($_) if -l $_; $devices{$_} = 1; } close $fh; } # Parse /etc/fstab my %disks; my %fstab_dev; my %fstab_uuid; my %fstab_label; sub parse_fstab($) { open( my $fh, "<", $_[0] ) || return; my @out; while (<$fh>) { my %h; s/#.*//; s/\s+$//; next if $_ eq ''; my ( $dev, $uuid, $label ) = ( '', '', '' ); if (s/^UUID=([^\s"]+)\s+//) { $uuid = $1; $h{uuid} = $1; } elsif (s/^UUID="([^"]+)"\s+//) { $uuid = $1; $h{uuid} = $1; } elsif (s/^LABEL=([^\s"]+)\s+//) { $label = $1; $h{label} = $1; } elsif (s/^LABEL="((?:[^"]|"")+)"\s+//) { $label = $1; $label =~ s/""/"/g; $h{label} = $1; } elsif (s/^([^\s"]+)\s+//) { $dev = $1; $h{dev} = $1; } else { next; } my @fields = split( /\s+/, $_ ); $h{mountpoint} = shift(@fields); $h{fs} = shift(@fields); my @opts = split( ',', shift(@fields) ); foreach my $opt (@opts) { $h{opts}->{$opt} = 1; } push @out, \%h; } close $fh; return @out; } sub parse_line($) { my $fields = $_[0]; my %h; while ( $fields =~ s/^\s*([^"]+)="([^\"]*)"\s*// ) { $h{$1} = $2; } my $dev = $h{KNAME}; if ( $h{TYPE} eq 'disk' ) { $disks{$dev} = \%h; } if ( $h{TYPE} eq 'part' ) { my $basedev = $dev; $basedev =~ s/\d+$//; foreach my $key ( keys %h ) { if ( $h{$key} eq '' ) { $h{$key} = $disks{$basedev}->{$key}; } } } return if $h{FSTYPE} eq ''; return if $h{FSTYPE} eq 'swap'; return if $h{FSTYPE} eq 'linux_raid_member'; return if $h{FSTYPE} eq 'LVM2_member'; # skip LVM partitions # return if $h{TYPE} eq 'lvm'; # skip FS in fstab return if defined $fstab_label{ $h{LABEL} }; return if defined $fstab_uuid{ $h{UUID} }; return if defined $fstab_dev{ "/dev/" . $h{KNAME} }; return \%h; } foreach ( parse_fstab "/etc/fstab" ) { if ( defined $_->{opts}->{user} ) { if ( defined $_->{dev} ) { my $dev = $_->{dev}; $dev = abs_path($dev) if -l $dev; $devices{$dev} = 1; } next; } if ( defined $_->{dev} ) { my $dev = $_->{dev}; $dev = abs_path($dev) if -l $dev; $fstab_dev{$dev} = 1; } $fstab_label{ $_->{label} } = 1 if defined $_->{label}; $fstab_uuid{ $_->{uuid} } = 1 if defined $_->{uuid}; } my @out; # Get all info about removable and USB devices open( my $fh, "-|", '/bin/lsblk', '-o', 'NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE,RM,KNAME,MODEL,TYPE,UUID', '-P' ); my $tb = Text::Table->new( 'NAME', 'MOUNTPOINT', 'LABEL', 'FSTYPE', "SIZE\n&left", 'MODEL' ); while (<$fh>) { my $h = parse_line($_); next unless defined $h; next unless defined $devices{ "/dev/" . $h->{KNAME} }; $tb->add( $h->{NAME}, $h->{MOUNTPOINT}, $h->{LABEL}, $h->{FSTYPE}, $h->{SIZE}, $h->{MODEL} ); my $dev = "/dev/" . $h->{KNAME}; push @out, $dev; } print $tb; --r5Pyd7+fXNt84Ff3-- --A6N2fC+uXW/VQSAv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlPZNVwACgkQPuR8c4jhFKJmpgCguTWVpTh5r1BM1pLYPXC3yS04 2CcAn3o3SAyrWKUKKop1RIb5Q7j9EimP =HKbN -----END PGP SIGNATURE----- --A6N2fC+uXW/VQSAv--