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=Y+C/g1+7oMz4OzFfRmZfWCSInHDr9AaR7acRAux7TfI=; b=S4sVHaVBLnoHFE7Nv4s4HsNq3MfhAf1L/6tCKycuAvRTSbZSx3bE2IWrHZEMxrlCY/ 74a9zSgHqKjlXMQfDaDJNvp3CwtHFASG4UUVL/j93R4J9sWEE4Yf0THbu59YcwwOReAw qT/NaJiZgaokjCc3KKLRKsZDsYN612xXFYFmioTFo20c1bVHEFef8NYwV4H+MhW2yKVw vqO7VW2vZzBudZMiuGXR2N5LUepzS5Jao2KJobKW/zIgOG/YBbO2rvRnWCKlS998KmFc yr2Yt/IkvjdmwUnxgNBovR0bTKyhoPieuKwedr+oTEUUo4Iz9+F2h0Jh52cJX3vNDK7x 5qBg== X-Received: by 10.153.4.6 with SMTP id ca6mr2256003lad.32.1406861021288; Thu, 31 Jul 2014 19:43:41 -0700 (PDT) Sender: Denis Smirnov Date: Fri, 1 Aug 2014 06:43:38 +0400 From: =?koi8-r?B?5MXOydMg883J0s7P1w==?= To: community@lists.altlinux.org Message-ID: <20140801024338.GA17027@mw.mithraen.ru> Mail-Followup-To: community@lists.altlinux.org References: <20140730005244.GB32238@mw.mithraen.ru> <1208071406690813@web8g.yandex.ru> <20140730181141.GA11396@mw.mithraen.ru> <292221406772030@web23h.yandex.ru> <20140731140622.GA8662@mw.mithraen.ru> <143291406817580@web22h.yandex.ru> <20140731164759.GA12540@mw.mithraen.ru> <560801406828159@web24j.yandex.ru> <20140731190534.GA20662@mw.mithraen.ru> <994901406854049@web16j.yandex.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LyciRD1jyfeSSjG0" Content-Disposition: inline In-Reply-To: <994901406854049@web16j.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: Fri, 01 Aug 2014 02:43:51 -0000 Archived-At: List-Archive: List-Post: --LyciRD1jyfeSSjG0 Content-Type: multipart/mixed; boundary="VS++wcV0S1rZb1Fb" Content-Disposition: inline --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 01, 2014 at 04:47:29AM +0400, Speccyfighter wrote: > =F7=D9=C8=CF=C4=C9=D4 =D4=C1=CB, =DE=D4=CF =CF=D0=D4=C9=DE=C5=D3=CB=C9=CA= =D0=D2=C9=D7=CF=C4 =C4=CC=D1 =CF=D4=CF=C2=D2=C1=D6=C5=CE=C9=D1 > =C4=CF=CC=D6=C5=CE =C2=D9=D4=D8 =C8=CF=D4=D8 =C7=C4=C5-=CE=C9=C2=D5=C4=D8= =D5=CB=C1=DA=C1=CE, > =C9=CC=C9 =D7 /etc/pmount.allow =C9=CC=C9 =D7 /etc/fstab > =EE=CF =DA=C4=C5=D3=D8 =DC=D4=CF =CE=C5=CF=C2=D1=DA=C1=D4=C5=CC=D8=CE=CF,= =C9 =D0=D2=C9 =CF=D4=D3=D5=D4=D3=D4=D7=C9=C9 =CD=C1=D4=D2=C9=C3=D9: =F3=D0=C1=D3=C9=C2=CF! =EE=C1=DB=C5=CC =D7=D4=CF=D2=D5=C0 =CF=DB=C9=C2=CB= =D5. =EF=C4=CE=C1=CB=CF =D1 =D3=D5=CD=C5=CC =D3=C4=C5=CC=C1=D4=D8 =C4=D7=C5= =C4=C5=D4=D3=CB=C9=C8 =CF=DB=C9=C2=CB=C9 =D7 =CB=D5=D3=CF=DE=CB=C5 =CB=CF=C4=C1 =C9=DA 4-=C8 =D3=D4=D2=CF=CB :) =F7 =D3=D4=D2=CF=CB=C5 24 =DA=C1=CD=C5=CE=C9=D4=C5, =D0=CF=D6=C1=CC=D5=CA= =D3=D4=C1: $devices{$1} =3D 1; =CE=C1 =09 $devices{'/dev/'.$1} =3D 1; =E9=D3=D0=D2=C1=D7=CC=C5=CE=CE=CF=C5 =D7 =C1=D4=D4=C1=DE=C5. > ...=CB=D3=D4=C1=D4=C9 =C4=C1, =D0=CF=DE=D4=CF=D7=C9=CB =D0=CF=CD=C5=CE=D1= =CC =D7=CF =D7=CC=CF=D6=C5=CE=C9=C9 =CB=CF=CE=C3=D9 =D3=D4=D2=CF=CB > =D3 LF =CE=C1 LF+CR (0A 0D). hex-=D7=D8=C0=D7=C5=D2 =D0=CF=CB=C1=DA=C1=CC. > =F0=D2=C9=DB=CC=CF=D3=D8 =CB=CF=CE=D7=C5=D2=D4=C5=D2=CF=CD dos2unix =D0= =CF =C6=C1=CA=CC=D5. =EB=D3=D4=C1=D4=C9 =DC=D4=CF =CD=CF=D6=CE=CF =D3=C4=C5=CC=C1=D4=D8 =C9 =D4= =C1=CB: $ sed -i 's/\r//' :) --=20 =F3 =D5=D7=C1=D6=C5=CE=C9=C5=CD, =E4=C5=CE=C9=D3 http://mithraen.ru/ --VS++wcV0S1rZb1Fb 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 RM,KNAME` ); foreach (@devs) { next unless /^1\s+(.+)$/; $devices{'/dev/'.$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; --VS++wcV0S1rZb1Fb-- --LyciRD1jyfeSSjG0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlPa/toACgkQPuR8c4jhFKIhQwCfezyAoDzcD7ww5QCb5NqX0h6+ XeoAn1AJgSneZIcQjwyRj9JGPEYl3CEl =AXOW -----END PGP SIGNATURE----- --LyciRD1jyfeSSjG0--