Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
663 views
in Technique[技术] by (71.8m points)

linux - Device number in stat command output

  stat test.log 
  File: `test.log'
  Size: 573         Blocks: 8          IO Block: 4096   regular file
Device: 804h/2052d  Inode: 7091301     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1001/   abc)   Gid: ( 1001/   abc)
Access: 2010-11-29 17:56:22.000000000 -0800
Modify: 2010-11-29 17:56:22.000000000 -0800
Change: 2010-11-29 17:56:22.000000000 -0800 

In the stat o/p above what does the Device entry signify ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It's the major and minor device number combined into one value (in hex and decimal) of the device on which the file resides.

For your example, 804h is major device 8, minor device 4. if you run df . while you're in the directory where that file is, you'll get the device name such as /dev/sda1. If you were to then do ls -al /dev/sda1, it would show you the device numbers. Here's an example:

pax$ stat newfile # note device 801h, hex 801 = 2049 decimal
  File: 'newfile'
  Size: 2097152     Blocks: 4096       IO Block: 4096   regular file
Device: 801h/2049d  Inode: 2888080     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     pax)   Gid: ( 1000/     pax)
Access: 2010-11-29 07:32:22.011271661 +0800
Modify: 2010-08-30 15:43:14.286796827 +0800
Change: 2010-08-30 15:43:14.286796827 +0800

pax$ df . # to get current device mount
Filesystem           1K-blocks Used Available Use% Mounted on
/dev/sda1            470301088 182471788 263939332  41% /

pax$ ls -al /dev/sda1 # to get major/minor = 8/1
brw-rw---- 1 root disk 8, 1 2010-11-30 07:02 /dev/sda1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...