Sorting Filenames - SMB

This is a discussion on Sorting Filenames - SMB ; Hi, sorry if this sounds like a silly question but I've not yet found a solution using google. I'm using samba 3.x on a linux system and accessing the shares on a windows 2k client. To me it looks like ...

+ Reply to Thread
Results 1 to 18 of 18

Thread: Sorting Filenames

  1. Sorting Filenames

    Hi,

    sorry if this sounds like a silly question but I've not yet found a
    solution using google.

    I'm using samba 3.x on a linux system and accessing the shares on a
    windows 2k client.

    To me it looks like file names are not sorted when accessing them via
    samba shares.

    If i do a dir c: for instance filenames are sorted, but if I do the same
    on a samba share they are not sorted. This causes some problems for me
    and I'd like to know if there is a way to make either windows sort them
    on its own (not in the explorer, but for every programm accessing these
    shares) or make samba sort them before sending them to the windows machine.

    Any help is appreciated.


    kind regards Philip

  2. Re: Sorting Filenames


    "Philip Lawatsch" wrote in message
    news:4114c908@e-post.inode.at...
    > Hi,
    >
    > sorry if this sounds like a silly question but I've not yet found a
    > solution using google.
    >
    > I'm using samba 3.x on a linux system and accessing the shares on a
    > windows 2k client.
    >
    > To me it looks like file names are not sorted when accessing them via
    > samba shares.
    >
    > If i do a dir c: for instance filenames are sorted, but if I do the same
    > on a samba share they are not sorted. This causes some problems for me
    > and I'd like to know if there is a way to make either windows sort them
    > on its own (not in the explorer, but for every programm accessing these
    > shares) or make samba sort them before sending them to the windows

    machine.
    >
    > Any help is appreciated.
    >
    >
    > kind regards Philip


    try DIR /ON to sort by name. DIR /? will show all the options.






  3. Re: Sorting Filenames

    m.marien wrote:

    >>I'm using samba 3.x on a linux system and accessing the shares on a


    >>To me it looks like file names are not sorted when accessing them via
    >>samba shares.


    > try DIR /ON to sort by name. DIR /? will show all the options.


    "Dir" was only an example. Files are not sorted in general and thats a
    problem.

    Is there a way to let samba sort them?


    kind regards Philip


  4. Re: Sorting Filenames - sorted.png (0/1)

    Philip Lawatsch wrote:

    >m.marien wrote:
    >
    >>>I'm using samba 3.x on a linux system and accessing the shares on a

    >
    >>>To me it looks like file names are not sorted when accessing them via
    >>>samba shares.

    >
    >> try DIR /ON to sort by name. DIR /? will show all the options.

    >
    >"Dir" was only an example. Files are not sorted in general and thats a
    >problem.
    >
    >Is there a way to let samba sort them?
    >
    >
    >kind regards Philip
    >

    and they may not be sitting on the hard disk side by side either..
    whats your point?

    if you want/need to browse them sorted, when browsing them on *most*
    windows applications, you can click on "views" on the file windows and
    then click on the column you want them sorted by. see attatched
    graphic from MS Office 2000

    keith

  5. Re: Sorting Filenames - sorted.png (0/1)

    keith wrote:

    > and they may not be sitting on the hard disk side by side either..
    > whats your point?
    >
    > if you want/need to browse them sorted, when browsing them on *most*
    > windows applications, you can click on "views" on the file windows and
    > then click on the column you want them sorted by. see attatched
    > graphic from MS Office 2000



    The point is that the behaviour is different. One quick example I found
    is that if you enqueue a folder in Winamp it will be sorted if the
    folder is on a local disk, and unsorted if its on a mount shared by samba.

    This also touches a lot of other apps. For instance I use "tree"
    sometimes to have a look on whats stored on a disk / mount. Try that on
    a samba share and then try to find anything ...


    Aw, I did not intend to start any sort of discussions, I just wanted to
    know if there is a solution for this.


    kind regards Philip

  6. Re: Sorting Filenames


    "Philip Lawatsch" wrote in message
    news:41160769$1@e-post.inode.at...
    > m.marien wrote:
    >
    > >>I'm using samba 3.x on a linux system and accessing the shares on a

    >
    > >>To me it looks like file names are not sorted when accessing them via
    > >>samba shares.

    >
    > > try DIR /ON to sort by name. DIR /? will show all the options.

    >
    > "Dir" was only an example. Files are not sorted in general and thats a
    > problem.
    >
    > Is there a way to let samba sort them?
    >


    Not Samba. Windows doesn't sort them on the disk either. The disk is random
    access, all the rest is smoke and mirrors I believe. However, if you copy
    them to another *new* directory with Windows Explorer they get copied in the
    sort order they are viewed in. If you want to copy them back to the original
    directory, you have to delete them from the original directory first or they
    get put in the same order they were. You could probaby use move. I've always
    used copy.

    This doesn't sort or defragment the files on the disk, it only sorts the
    entries in the directory. The move probably wouldn't even move the file
    contents, only the directory entries. If you need a specific order, copy
    them back one by one in the order that you require.




  7. Re: Sorting Filenames

    m.marien wrote:

    > Not Samba. Windows doesn't sort them on the disk either. The disk is random
    > access, all the rest is smoke and mirrors I believe. However, if you copy
    > them to another *new* directory with Windows Explorer they get copied in the
    > sort order they are viewed in. If you want to copy them back to the original
    > directory, you have to delete them from the original directory first or they
    > get put in the same order they were. You could probaby use move. I've always
    > used copy.
    >
    > This doesn't sort or defragment the files on the disk, it only sorts the
    > entries in the directory. The move probably wouldn't even move the file
    > contents, only the directory entries. If you need a specific order, copy
    > them back one by one in the order that you require.


    E:\test>mkdir a
    E:\test>mkdir b
    E:\test>mkdir c
    E:\test>mkdir z
    E:\test>mkdir d

    E:\test>tree /A
    E:.
    +---a
    +---b
    +---c
    +---d
    \---z

    So if thats true then why are these folders sorted?

    E is a local drive, now lets use a samba share:

    X:\test>mkdir a
    X:\test>mkdir b
    X:\test>mkdir c
    X:\test>mkdir z
    X:\test>mkdir d

    X:\test>tree /A
    X:.
    +---a
    +---b
    +---c
    +---z
    \---d

    This is what I want to have changed.

    kind regards Philip


  8. Re: Sorting Filenames

    Philip Lawatsch wrote:



    > This is what I want to have changed.


    And, just as a side note, the same thing on a share coming from a w2k
    machine:

    W:\test>mkdir a
    W:\test>mkdir b
    W:\test>mkdir c
    W:\test>mkdir z
    W:\test>mkdir d

    W:\test>tree /A
    W:.
    +---a
    +---b
    +---c
    +---d
    \---z

    As you can see there definitely is a difference in w2k<->w2k and
    w2k<->samba.


    kind regards Philip

  9. Re: Sorting Filenames

    Philip Lawatsch writes:
    >m.marien wrote:
    >
    >>>I'm using samba 3.x on a linux system and accessing the shares on a

    >
    >>>To me it looks like file names are not sorted when accessing them via
    >>>samba shares.

    >
    >> try DIR /ON to sort by name. DIR /? will show all the options.

    >
    >"Dir" was only an example. Files are not sorted in general and thats a
    >problem.
    >
    >Is there a way to let samba sort them?


    Operating systems do not sort files. That's up to your directory
    application. Windows file explorer and Unix 'ls' sort files differently
    - some are case sensitive, some are not, some sort folders to the
    beginning, some don't. There is no generally accepted way of doing it.


    --
    "The road to Paradise is through Intercourse."
    [email me at huge [at] huge [dot] org [dot] uk]



  10. Re: Sorting Filenames

    Huge wrote:


    > Operating systems do not sort files. That's up to your directory
    > application. Windows file explorer and Unix 'ls' sort files differently
    > - some are case sensitive, some are not, some sort folders to the
    > beginning, some don't. There is no generally accepted way of doing it.


    Well, you can read my other posts. The very same applications (dir, tree
    et al) seem to see all files sorted on local drives but unsorted on
    drives shared by samba (but sorted on shares shared by another windows
    machine). So there is a difference, and I'd like to find a solution for
    this.

    kind regards Philip

  11. Re: Sorting Filenames


    "Philip Lawatsch" wrote in message
    news:41162b0d$1@e-post.inode.at...
    > Philip Lawatsch wrote:
    >
    >
    >
    > > This is what I want to have changed.

    >
    > And, just as a side note, the same thing on a share coming from a w2k
    > machine:
    >
    > W:\test>mkdir a
    > W:\test>mkdir b
    > W:\test>mkdir c
    > W:\test>mkdir z
    > W:\test>mkdir d
    >
    > W:\test>tree /A
    > W:.
    > +---a
    > +---b
    > +---c
    > +---d
    > \---z
    >
    > As you can see there definitely is a difference in w2k<->w2k and
    > w2k<->samba.
    >
    >
    > kind regards Philip


    Looks that way eh? So the question would be, is the sorting done by the
    listing function or sorted by the o/s. I would have thought that it's done
    by the listing fuction for two reasons. First, the order on the disk is
    random. The Linux function ls -U lists the files in unsorted order on both
    Linux and Windows shares. There is no benefit for the o/s to sort the list,
    only speed penalties. It also doesn't know what sort order is required.
    Second, most listing function have sorting options suggesting that it
    controls that feature.

    I did some further experiments. As I explained, copying or moving the files
    with Windows Explorer also sorts them in the new directory. This doesn't
    work across the Samba share to a Linux file system. The order is preserved
    for copying and reversered when moving or something like that. I also tried
    this with Linux over Samba shares. When the share is to a windows share the
    Linux functions cp/mv preserve the order. When the share is to a Linux share
    they sort. Go figure eh.

    So when you share file systems (Linux <> Windows) with a Samba share there
    is no sorting. When you share the same file system (Linux<>Linux) or
    (Windows<>Windows) with a Samba share sorting takes place on a number of
    functions both Windows and Linux. So IMHO I don't think Samba is to blame,
    but rather the mapping of functions is not complete when you operate between
    different file systems.

    If you need a solution, my previous suggestion still works. You can use the
    Linux mv function to sort the directories.






  12. Re: Sorting Filenames

    Philip Lawatsch schrieb:

    > As you can see there definitely is a difference in w2k<->w2k and
    > w2k<->samba.


    That should be a problem on samba then.
    All directory entries are alphabetically unsorted in general, but sorted
    chronologically (creation date). So sorting by alphabet is a job for the
    filebrowser or listing-command.

    But in your case i there is maybe a kind of missed short-filename (8.3)
    problem. Probably there is a difference how samba presents directory
    list to your client in oposit to windows presents its shares. So it
    depends on your clients capabilities to handle sorting mechanisms on
    this. But there you seem to have a problem.
    You've said the explorer is not the problem but any other windows
    applications!? Then probably you talk about some 16bit windows
    applications. And then you NEED 8.3 variants of file directory entries
    to handle them correctly.

    I think support for 8.3 filnaming convention is disabled at samba. But i
    dont't know if there is any way how to activate/deactivate it. It was
    only a theoretical try for a solution..


    Greetings

    Manuel

  13. Re: Sorting Filenames

    Manuel Kraus wrote:
    > Philip Lawatsch schrieb:
    >
    >> As you can see there definitely is a difference in w2k<->w2k and
    >> w2k<->samba.

    >
    >
    > That should be a problem on samba then.
    > All directory entries are alphabetically unsorted in general, but sorted
    > chronologically (creation date). So sorting by alphabet is a job for the
    > filebrowser or listing-command.


    I do agree, and in principle I'm fine with that. But the problem is that
    samba and windows behave differently in this case.

    > But in your case i there is maybe a kind of missed short-filename (8.3)
    > problem. Probably there is a difference how samba presents directory
    > list to your client in oposit to windows presents its shares. So it
    > depends on your clients capabilities to handle sorting mechanisms on
    > this. But there you seem to have a problem.
    > You've said the explorer is not the problem but any other windows
    > applications!? Then probably you talk about some 16bit windows
    > applications. And then you NEED 8.3 variants of file directory entries
    > to handle them correctly.


    I'm talking about applications like "dir" or "tree" which are supplied
    with windows. I do doubt that it has to do with 8.3.

    kind regards Philip

  14. Re: Sorting Filenames

    m.marien wrote:

    > If you need a solution, my previous suggestion still works. You can use the
    > Linux mv function to sort the directories.


    Problem is that this is only a solution for existing files, but not for
    new ones.

    I think I'm gonna drop a mail to the samba mailing list, perhaps someone
    else reading this list already had this problem.

    kind regards Philip

  15. Re: Sorting Filenames

    Philip Lawatsch schrieb:

    > I do agree, and in principle I'm fine with that. But the problem is that
    > samba and windows behave differently in this case.
    >
    > I'm talking about applications like "dir" or "tree" which are supplied
    > with windows. I do doubt that it has to do with 8.3.


    Okay, command line commands should support both variants, agreed. At the
    DIR command, for example, there are both views possible. But the way to
    achive those needed informations could be different.

    What about an eventually deactivated 8.3 compability mode at your
    _client side_? I know there was something like this at NT 4 (W2K?), a
    service maybe. That you can see the windows shares correctly, must not
    say that the way is the same.
    So this support should be on both sides, server and client. Maybe the
    WINDOWS server goes another way to transport this extra information for
    its shares in opposit to samba, so a client side lack of such support
    could cause such misbehvior too.
    I'm no programmer, but i know of the problem of different standards and
    different research levels..

    Here is my statement ;-) :

    The directory sort function goes into the nirvana, because of an empty
    8.3 filename table. Maybe yes, maybe not..


    Manuel

  16. Re: Sorting Filenames

    Philip Lawatsch writes:
    >Huge wrote:
    >
    >
    >> Operating systems do not sort files. That's up to your directory
    >> application. Windows file explorer and Unix 'ls' sort files differently
    >> - some are case sensitive, some are not, some sort folders to the
    >> beginning, some don't. There is no generally accepted way of doing it.

    >
    >Well, you can read my other posts. The very same applications (dir, tree
    >et al) seem to see all files sorted on local drives but unsorted on
    >drives shared by samba (but sorted on shares shared by another windows
    >machine). So there is a difference, and I'd like to find a solution for
    >this.


    Windows behaves differently between local and shared drives. It's broken.
    In this as so many other ways.


    --
    "The road to Paradise is through Intercourse."
    [email me at huge [at] huge [dot] org [dot] uk]



  17. Re: Sorting Filenames

    Huge wrote:
    > Philip Lawatsch writes:
    >
    >>Huge wrote:
    >>
    >>
    >>
    >>>Operating systems do not sort files. That's up to your directory
    >>>application. Windows file explorer and Unix 'ls' sort files differently
    >>>- some are case sensitive, some are not, some sort folders to the
    >>>beginning, some don't. There is no generally accepted way of doing it.

    >>
    >>Well, you can read my other posts. The very same applications (dir, tree
    >>et al) seem to see all files sorted on local drives but unsorted on
    >>drives shared by samba (but sorted on shares shared by another windows
    >>machine). So there is a difference, and I'd like to find a solution for
    >>this.

    >
    >
    > Windows behaves differently between local and shared drives. It's broken.
    > In this as so many other ways.


    Granted, but imho it should behave the same no matter if the share comes
    from a different windows or samba machine.


    kind regards Philip

  18. Re: Sorting Filenames


    "Philip Lawatsch" wrote in message
    news:41174493@e-post.inode.at...
    > Huge wrote:
    > > Philip Lawatsch writes:
    > >
    > >>Huge wrote:
    > >>
    > >>
    > >>
    > >>>Operating systems do not sort files. That's up to your directory
    > >>>application. Windows file explorer and Unix 'ls' sort files differently
    > >>>- some are case sensitive, some are not, some sort folders to the
    > >>>beginning, some don't. There is no generally accepted way of doing it.
    > >>
    > >>Well, you can read my other posts. The very same applications (dir, tree
    > >>et al) seem to see all files sorted on local drives but unsorted on
    > >>drives shared by samba (but sorted on shares shared by another windows
    > >>machine). So there is a difference, and I'd like to find a solution for
    > >>this.

    > >
    > >
    > > Windows behaves differently between local and shared drives. It's

    broken.
    > > In this as so many other ways.

    >
    > Granted, but imho it should behave the same no matter if the share comes
    > from a different windows or samba machine.
    >


    I think it does the best it can, at no fault of Samba. If you try the tests
    I described earlier in this thread you will see the problem is not with
    Samba, but with the differences in the file systems. Windows functions on a
    Windows share work fine. So do Linux functions on a Linux file system over
    Samba share. However, as you pointed out, Windows functions do not behave as
    expected on a Linux file system over a Samba share. And as I discovered,
    Linux functions do not work as expected on a Windows file system over a
    Samba share. So it's not the Samba system, as Linux functions work just fine
    across a Samba share on a Linux file system.

    IMHO I think the problem is the mapping of functions between file systems.
    NTFS low level functions do not map to Linux requests well, nor do Linux
    disk low level functions map to DOS requests very well. You can't blame the
    messenger (Samba) for that.



+ Reply to Thread