# FreeBSD device file path



## prady (Oct 3, 2012)

Hello guys,
In linux we can find major number of a device under /proc/devices but I am not sure where we can find the major number of a device file in FreeBSD. Please let me know.

Thank You


----------



## fluca1978 (Oct 29, 2012)

Uhm...I suspect that due to devfs(4) there is no major number at all.
Maybe someone can provide more information.


----------



## SirDice (Oct 29, 2012)

Why do you need it?


----------



## fluca1978 (Oct 30, 2012)

fluca1978 said:
			
		

> Uhm...I suspect that due to devfs(4) there is no major number at all.
> Maybe someone can provide more information.



Seems to me that even OpenBSD, while not using devfs, does not assign major number to block devices (while it does with character ones).


----------



## SirDice (Oct 30, 2012)

There are no block devices anymore, they're all character devices.

http://www.freebsd.org/doc/en/books/arch-handbook/driverbasics-block.html


----------



## fluca1978 (Oct 30, 2012)

SirDice said:
			
		

> There are no block devices anymore, they're all character devices.
> 
> http://www.freebsd.org/doc/en/books/arch-handbook/driverbasics-block.html



Correct, and I'm trying to remove my doubts about this in another thread. What I was saying here is that on OpenBSD disks are marked with the _b_ of block devices and the _c_ in the case of the raw interface, while in FreeBSD they are all marked as _c_.


----------



## SirDice (Oct 30, 2012)

Are you refering to the _c_ in for example ada0s1c? That 'c' is for 'complete', not character. It existed long before block devices where removed.

An old 4.0 man page for disklabel(8) says:

```
Disk device name
     All disklabel forms require a disk device name, which should always be
     the raw "complete" (or "c") partition, for example /dev/rda0c.  disklabel
     understands the abbreviation da0, which it converts internally to
     /dev/rda0c.
```


----------



## fluca1978 (Oct 30, 2012)

No, I was referring to the _c_ in the ls(1) output.
This is an example from one of my FreeBSD box:


```
# ls -l /dev/ad0*
[B]c[/B]rw-r-----  1 root  operator    0,  64 Oct 30 08:09 /dev/ad0                              
[B]c[/B]rw-r-----  1 root  operator    0,  65 Oct 30 08:09 /dev/ad0s1                            
[B]c[/B]rw-r-----  1 root  operator    0,  66 Oct 30 08:09 /dev/ad0s1a                           
[B]c[/B]rw-r-----  1 root  operator    0,  67 Oct 30 08:09 /dev/ad0s1b
```


----------



## SirDice (Oct 30, 2012)

Ah, that _c_. Yes, you are correct, that's to indicate a character device.


----------



## fluca1978 (Oct 31, 2012)

I've checked The Book (i.e., the McKusick's book) and the major number is still there for retro-compatibility, but it is no more used in FreeBSD. So I guess this also means that there is no way at all to get a major number of any device.


----------



## SirDice (Oct 31, 2012)

If I remember correctly you can tell just by listing the files. Taking fluca1978's example:

```
# ls -l /dev/ad0*
crw-r-----  1 root  operator    [b]0,  64[/b] Oct 30 08:09 /dev/ad0                              
crw-r-----  1 root  operator    [b]0,  65[/b] Oct 30 08:09 /dev/ad0s1                            
crw-r-----  1 root  operator    [b]0,  66[/b] Oct 30 08:09 /dev/ad0s1a                           
crw-r-----  1 root  operator    [b]0,  67[/b] Oct 30 08:09 /dev/ad0s1b
```
The numbers in bold should be the major and minor numbers. But I don't think they're of any use.


----------



## fluca1978 (Oct 31, 2012)

SirDice said:
			
		

> If I remember correctly you can tell just by listing the files. Taking fluca1978's example:
> 
> ```
> # ls -l /dev/ad0*
> ...



Correct, the 0 is the major and the other are minor ones. The driver is in charge of selecting the new minor (i.e., the instance number), while the major was used as an index into the driver table within the kernel.


----------



## fluca1978 (Nov 2, 2012)

As a final note, the make_dev(9) specifies that even the unit number is no more required (as far as I understand) since it is returned automatically from the system and there is no way to specify the major number.


----------



## prady (Nov 3, 2012)

Thank You Guys.


----------

