[Novalug] linux fundamentals (VEQ)

Don E. Groves, Jr. dgrovesjr@gmail.com
Tue Mar 10 21:56:53 EDT 2015


On Tue, Mar 10, 2015 at 4:31 PM, Jon LaBadie via Novalug <
novalug@firemountain.net> wrote:

> On Tue, Mar 10, 2015 at 03:00:53PM -0400, Rich Kulawiec via Novalug wrote:
> >
> > Here's an example of a block device:
> >
> >       % ls -ls /dev/sda*
> >       0 brw-rw---- 1 root disk 8, 0 Feb 22 06:52 /dev/sda
> >       0 brw-rw---- 1 root disk 8, 1 Feb 22 06:52 /dev/sda1
> >       0 brw-rw---- 1 root disk 8, 2 Feb 22 06:52 /dev/sda2
> >       0 brw-rw---- 1 root disk 8, 3 Feb 22 06:52 /dev/sda3
> >
> > Those are block devices ("b") of type 8, and they are the 0'th,
> > 1st, 2nd, and 3rd instances of such devices.  If I open() one of
> > those up and start reading blocks, then the blocks that I ask for
> > will be provided by the device driver for type 8 devices -- which
> > in this case is the sd (SCSI disk) driver.
> >
> > (Why are there four?  The 0'th is the entire disk.  The other three
> > are partitions on the disk.)
>
> UNIX systems provided both block and character devices for the disk
> and partitions.  I don't see an equivalent in Linux, is there one?
>
> The char devices were call "raw" devices.  The only "raw" I have is
> hidrawX which I assume is a Human Interface Device, not a disk.
>
> Jon
>

Ah  Linux tends to use slightly different names then UNIX or bsd
  But:
      0 brw-rw---- 1 root disk 8, 0 Feb 22 06:52 /dev/sda
           is a BLOCK device
     crw-rw-rw-  1 root  wheel    4, 0 Jan 28 15:28 /dev/ttyp0
          is a CHARACTER device
           ( note the character device reference is from a different
unix/bsd like OS,
             but Linux based systems look the same with maybe a different
name. )

    In computing <http://en.wikipedia.org/wiki/Computing>, specifically
Unix-like operating systems, a *raw device* is a special kind
    of block device <http://en.wikipedia.org/wiki/Block_device> file that
allows accessing a storage device such as a hard disk drive
    directly, bypassing the operating system's caches and buffers (although
the hardware
    caches might still be used).
     .........
     On Linux raw devices were deprecated and scheduled for removal at one
point,
     because the O_DIRECT flag can be used instead. However, later the
decision was
     made to keep raw devices support since some software cannot use the
O_DIRECT
     flag. Raw devices simply open block devices as if the O_DIRECT flag
would have
     been specified. Raw devices are character devices (major number 162).
        See:  Wikipedia raw device <http://en.wikipedia.org/wiki/Raw_device>


So yes if a "raw device" for the device you want/need doesn't exist you can
always create it.
Or you can simply open the device with the O_DIRECT flag.


Unless I don't understand your question/statement.

-- 
--
Don E. Groves, Jr.

Tag it's your turn now... ... ....



More information about the Novalug mailing list