LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-20-2009, 04:45 AM   #1
jbarelds
LQ Newbie
 
Registered: Jan 2009
Posts: 9

Rep: Reputation: 1
Samba file list ordering


Hi all,

I've published a samba share on a Ubuntu 8.10 server, and mounted the share on a windows box. For some strange reason the files are not sorted by file name (nor by any other sorting type) if I list them from the Windows command line (dir). I could always use the "dir /on" parameter, but I hope there's a way to make samba sort the files for me.

Issueing the ls command from a linux shell in the same directory does produce a nicely name-sorted list.
 
Old 08-20-2009, 05:24 AM   #2
rizhun
Member
 
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268

Rep: Reputation: 47
I believe the sorting is done by the OS that's on the share and not Samba.

Think you'll have to use 'DIR /ON' in DOS.
 
Old 08-20-2009, 06:04 AM   #3
jbarelds
LQ Newbie
 
Registered: Jan 2009
Posts: 9

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by rizhun View Post
I believe the sorting is done by the OS that's on the share and not Samba.

Think you'll have to use 'DIR /ON' in DOS.
If that's true, then I don't understand why a dir command on the local NTFS volume (any directory) of the Windows box always produces a neatly filename-ordered list.
 
Old 08-20-2009, 07:12 AM   #4
vishesh
Member
 
Registered: Feb 2008
Distribution: Fedora,RHEL,Ubuntu
Posts: 661

Rep: Reputation: 66
I think rizhun is right, samba is nor responsible for sorting

thnks
 
Old 08-21-2009, 02:45 AM   #5
jbarelds
LQ Newbie
 
Registered: Jan 2009
Posts: 9

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by vishesh View Post
I think rizhun is right, samba is nor responsible for sorting

thnks
To sum up what we have here:
- Local NTFS using 'dir' command w/o parameters: sorted by name
- Samba (ext3) using 'dir' command w/o parameters: no sorting whatsoever
- Same ext3 dir using 'ls' command w/o parameters: sorted by name

Been doing some reading, and I think I know why the above happens. NTFS has a so-called "Master File Table" (MFT), which describes all file properties per directory. The 'dir' command uses this information to build the file list, and apparently the files are sorted by name in the MFT. The ext3 volume does not seem to have a MFT equivalent, I think the 'ls' command does the sorting by name by default, at least --help seems to indicate that:

--sort=WORD: sort by WORD instead of name: none -U, extension -X, size -S, time -t, version -v

A 'dir' command on the ext3 (samba) FS will not find an MFT nor will it perform sorting by default, so files are shown in the order they're actually stored on disk.

Please correct me if I've gone horribly wrong somewhere.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pick random file name from a list of filenames in a text file. pdklinux79 Linux - Newbie 9 06-20-2008 02:46 PM
java list selection ordering: trscookie Programming 1 01-29-2008 06:55 AM
Need to find if a matching file exist from a list of possible file names wit_273 Linux - General 5 10-25-2007 09:47 AM
Logon samba on other samba password list hernandi Linux - Networking 1 10-14-2003 12:46 PM
Logon samba on other samba password list hernandi Linux - Networking 0 10-14-2003 12:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration