[VM] non-MacRoman file names

Richard A. O'Keefe ok at cs.otago.ac.nz
Thu Nov 27 03:29:41 UTC 2003


I wrote a bunch of stuff about FILENAME_MAX and pathconf().
	     The integer constant FILENAME_MAX specifies  the  number  of
	     bytes  needed to hold the longest pathname of a file allowed
	     by the implementation.  If the system does not impose a max-
	     imum  limit, this value is the recommended size for a buffer
	     intended to hold a file's pathname.
	
It occurred to me belatedly that UNIX has no strict limit on the length
of a name that you *might* want.

Suppose you have N discs (or disc partitions).
disc 0 is /
disc 1 is mounted as <long name 1> on /
disc 2 is mounted as <long name 2> on (disc 1/)
...
disc N-1 is bounded as <long name N-1> on (disc N-2/)

For each of these N directories, pathconf(".", _PC_NAME_MAX) will allow
quite a long name.  Suppose each of those names is pushing that limit.

Now, the operating system might not accept
/<long name 1>/<long name 2/.../<long name N-1>/<long name N>
in one gulp, *BUT* if your UNIX system supports openat(), you can
do it a piece at a time.

    d0 = open("/", whatever);
    while there is another chunk {
        d1 = openat(d0, next chunk, whatever);
        close(d0);
    }

So the longest file name you can *pass* isn't necessarily the same
as the longest file name you can *use*, and the latter needn't have
any fixed bound.

Gosh, don't computers make life simple!




More information about the Squeak-dev mailing list