[cs631apue] The confusing output of Linux/GNU ls
zding4
zding4 at stevens.edu
Thu Oct 16 22:15:54 EDT 2014
I find some very confusing output of Linux ls when I play it.
here is the output
zding4 at avatar:~/apue/midterm$ ls -ls
total 52
1 -rw-r--r--+ 1 zding4 student 37 Oct 13 21:33 Makefile
21 -rwxr-xr-x+ 1 zding4 student 20060 Oct 16 20:02 a.out
3 -rw-r--r--+ 1 zding4 student 1634 Oct 16 20:04 alink
3 -rw-r--r--+ 1 zding4 student 1173 Oct 13 14:30 chldlist.c
1 -rw-r--r--+ 1 zding4 student 0 Oct 14 15:24 dfsf?????????bla.txt
2 drwxr-xr-x+ 2 zding4 student 2 Oct 16 19:20 empty
3 -rw-r--r--+ 1 zding4 student 1598 Oct 16 20:04 file2
2 -rw-r--r--+ 1 zding4 student 748 Oct 12 22:44 l.h
17 -rw-r--r--+ 1 zding4 student 11408 Oct 16 20:25 ls.c
1 -rw-r--r--+ 1 zding4 student 0 Oct 13 21:47 out
1 lrwxrwxrwx 1 zding4 student 5 Oct 16 20:12 slink -> file1
2 d-wx--x--x+ 3 zding4 student 3 Oct 16 18:48 test
first is that
1+21+3+3+1+2+3+2+17+1+1+2 != 52
The size of test directory is only 3 but it takes 2 blocks
Any idea why this happen?
When I implement ls,
The block number is `st_size/BLOCKSIZE`
And the total is the sum of files' block number.
More information about the cs631apue
mailing list