LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-23-2010, 07:39 AM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Puzzled by ls output for /media directory


Hello

I'm puzzled by ls -l output for the /media directory and realised I don't fully understand what the ls long output columns show. The ls man page did not help. Here's the puzzling output
Code:
root@CW8:/media# ls -ld README hd* dvd*
-rw-r--r-- 1 root root  500 2006-09-26 08:44 README
lrwxrwxrwx 1 root root    4 2010-02-21 15:18 dvd -> dvd0
drwxr-xr-x 2 root root    1 2006-09-26 06:20 dvd0
drwxr-xr-x 2 root root    1 2006-09-26 06:20 dvd1
lrwxrwxrwx 1 root root    3 2010-02-21 15:18 hd -> hd0
drwxr-xr-x 2 root root 4096 2010-03-15 11:13 hd0
drwxr-xr-x 2 root root    1 2006-09-26 06:33 hd1
What does the second column mean? I thought it was a hard link count but
Code:
root@CW8:~# find / -xdev -samefile /media/hd0
/media/hd0
[no further output]
The fifth column is the size of the file in bytes. That's why README is listed, to show that's reasonable.

symlinks dvd and hd have fifth column (spies!) figures the size of their target names. Reasonable but aren't such short names kept in the directory entries (dirents) themselves so such symlinks are not files; their file size should be zero ???

Regards the directory file sizes being 1 or 4096, a few files were written to hd0 while no file system was mounted on it. Presumably that made it grow to accommodate dirents and it went from being a dirent alone to being a dirent plus an inode so it had space to store dirents for its own files. The reported 4096 presumably represents this single inode. But why are the other directories' sizes 1? If my speculation is correct, these directories which have only ever been used as mount points so have never "contained any files" are implemented purely in dirents in their parent' directory -- so, like symlinks with short target names, they are not files; their file size should be zero ???



Best

Charles

Last edited by catkin; 03-23-2010 at 07:41 AM. Reason: Better sense
 
Old 03-23-2010, 08:11 AM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
The second column is a number which tells how many directory entries are under that item. For a regular file, this will typically be 1. For a directory, this will always be at least 2.
http://docweb.cns.ufl.edu/docs/d0107/ar07s04.html

The reported size of a symlink is the number of characters in the path it points to.

Last edited by troop; 03-23-2010 at 08:16 AM.
 
1 members found this post helpful.
Old 03-23-2010, 08:45 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Original Poster
Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Thanks troop Link bookmarked.
 
  


Reply

Tags
inode, ls, symlink


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
usbdisk is not not showing in /media directory kadhan Red Hat 1 02-02-2009 10:54 AM
is it safe to remove /media directory? johngreenwood Slackware 2 12-26-2006 01:37 PM
puzzled by grepping on man output -- some strings found, others not tphyahoo Linux - Software 5 11-19-2006 01:17 PM
Media player output text file for now playing Berticus Linux - Software 0 08-04-2006 11:05 PM
Latex output directory feri79 Linux - Software 2 04-25-2005 06:40 AM


All times are GMT -5. The time now is 11:48 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration