LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-30-2016, 08:45 AM   #1
Joy Stick
Member
 
Registered: Dec 2015
Distribution: RHEL 4.7
Posts: 61

Rep: Reputation: Disabled
Want to list out using single command


Hi all;

Tried to diplay output just using 1 command.

PHP Code:
# raw -qa
/dev/raw/raw1:  bound to major 8minor 17
/dev/raw/raw2:  bound to major 8minor 33
/dev/raw/raw3:  bound to major 8minor 49
/dev/raw/raw4:  bound to major 8minor 65 
PHP Code:
# ls -l /dev/* | grep '8,  17'
brw-rw----  1 root disk     8,  17 Jan 30 16:16 /dev/sdb1
#  ls -l /dev/* | grep '8,  33'
brw-rw----  1 root disk     8,  33 Jan 30 16:16 /dev/sdc1 
I tried following options - but got error
PHP Code:
# ls -l /dev/* | grep '8,  17','8,  33'
# ls -l /dev/* | grep '8,  17'| grep '8,  33'
# ls -l /dev/* | grep '8,  17', grep '8,  33'
grepgrepNo such file or directory
grep
8,  33No such file or directory 
Thanks in advance
 
Old 01-30-2016, 09:42 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
grep takes a single pattern.... After that everything is treated as a file name.

Also note - what may be output by the ls could have tab characters (or multiple), It looks like the pattern you are using has spaces.

Also using a comma to separate two patterns doesn't work (it looks like you are searching for files with device numbers 8,17 or 8,33).

The second command you give the grep will not work, but you can try:
Code:
grep -e ' 8, *\(17\|\33\) '
This looks for the pattern <space>8,<0 or more spaces>17... or 33... followed by a space. The \ for the grouping and alternatives are required.

Last edited by jpollard; 01-30-2016 at 09:44 AM.
 
1 members found this post helpful.
Old 01-30-2016, 10:31 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,243

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Maybe it would be more useful if you told us what you are trying to do instead of showing us things which may or may not be what you are looking for?
 
Old 01-30-2016, 03:47 PM   #4
Joy Stick
Member
 
Registered: Dec 2015
Distribution: RHEL 4.7
Posts: 61

Original Poster
Rep: Reputation: Disabled
Hi

Using fdisk operation i have created some partitions.
Using raw utility i bound raw devices with block devices.

Ex : raw /dev/raw/raw1 /dev/sdb1

# raw -qa
/dev/raw/raw1: bound to major 8, minor 17
/dev/raw/raw2: bound to major 8, minor 33
/dev/raw/raw3: bound to major 8, minor 49
/dev/raw/raw4: bound to major 8, minor 65

Here my confusions

What indicates major/minor number for a device ?
I read linux treating each device as a file - Why so ?
Why linux treats /dev/raw/raw1 as a file instead of SCSI disk ?

Actually /dev/sdb1 is bound with /dev/raw/raw1 using raw utility.

Thanks
 
Old 01-30-2016, 04:24 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by Joy Stick View Post
Hi

Using fdisk operation i have created some partitions.
Using raw utility i bound raw devices with block devices.

Ex : raw /dev/raw/raw1 /dev/sdb1

# raw -qa
/dev/raw/raw1: bound to major 8, minor 17
/dev/raw/raw2: bound to major 8, minor 33
/dev/raw/raw3: bound to major 8, minor 49
/dev/raw/raw4: bound to major 8, minor 65
Waste of time. Just use the block devices directly. You get identical performance.
Quote:
Here my confusions

What indicates major/minor number for a device ?
Nothing. Linux only provides them for some legacy operations. If you actually look you find that the device name is dynamically generated, but the major/minor numbers are not used. ORIGINALLY, the major number was the index in the driver tables that corresponded to pointers to the driver functions. The minor number was provided to the driver functions to identify which unit to use. Unfortunately (and a LONG time ago) these indexes became useless (too many different kinds of drivers, some with too many units).
Quote:
I read linux treating each device as a file - Why so ?
simplicity. All the file name entry does is identify which driver to use for various functions. Current linux design has the /dev directory as a pseudo filesystem - it doesn't really exist. The in memory data structures are being interpreted as a filesystem, and the device structure (a collection of pointers to the driver functions) are assigned to a name during the initial hardware scan. That is why the filesystem type is "devtmpfs". It isn't a real filesystem. As each driver initializes it registers itself to the kernel devtmpfs filesystem which records the appropriate entry.
Quote:
Why linux treats /dev/raw/raw1 as a file instead of SCSI disk ?
Everything is a file... There is no difference between /dev/raw/raw1 and using the /dev names.
Quote:

Actually /dev/sdb1 is bound with /dev/raw/raw1 using raw utility.
So what. Both names are linked to the same device driver. This was one of the reasons the raw interface was considered to be redundant and could be dropped.

If you actually look, the /dev/disk directory entries (by-id, by-label, by-partuuid, by-path, and by-uuid) just supply symbolic links the base /dev/<name> for the disk. I believe the /dev/raw entries are the same.

If you use the raw entries, you have additional restrictions - you have to use block aligned data transfers (and use page aligned memory buffers)... and that slows down and makes things more complicated for the application. Letting the kernel handling the buffers makes for a faster and more flexible operation by letting the page cache handle the I/O scheduling.
Quote:
Thanks
No problem.

Last edited by jpollard; 01-30-2016 at 04:39 PM.
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
want to list output in single line (space separated) saini_mw Linux - Newbie 8 02-01-2011 11:02 PM
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 08:19 PM
xorg.conf select single screen from list Meson Linux - General 3 11-23-2007 09:25 AM
Why does acpi list CPU0 as CPU1 on a single CPU machine? mdmaddux Slackware 1 08-07-2007 06:01 PM
Play single sound from list edgjerp Linux - Software 1 02-24-2007 02:20 PM


All times are GMT -5. The time now is 03:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration