Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

UNIX File System

6 views
Skip to first unread message
Message has been deleted

Alan Rollow - Dr. File System's Home for Wayward Inodes.

unread,
Feb 20, 1998, 3:00:00 AM2/20/98
to

In article <34EBAD21...@cornell.edu>, Howard Yen <ht...@cornell.edu> writes:
>
>Does anyone know what is the limit on the number of directories within a
>directory that UNIX can have?

It will depend on the particular UNIX and file system implementation
being used. The limit will probably be based on the maximum number
of hard links a particular file can have. There may be a constant
defined somewhere such as LINK_MAX that defines the limit, or it
may be implied by the type of nlink_t. Older systems may simply
use one of the base types; unsigned short or short.

Digital UNIX has a limit of 32767 and ULTRIX has a limit of 32766.
HP-UX A.09.05 appears to have a limit of 32767.

>
>
--
Alan Rollow al...@nabeth.cxo.dec.com


Hans-Dieter Wunderlich

unread,
Feb 25, 1998, 3:00:00 AM2/25/98
to

Howard Yen wrote:
>
> Does anyone know what is the limit on the number of directories within a
> directory that UNIX can have?

According to X/OPEN (XPG4, Version 2) there is a system constant
LINK_MAX, restricting the number of links for a file. As each directory
means a link to the parent directory, this also restricts the number of
subdirectories of a given directory.
The actual value on your system can be looked up in <limits.h>.

HDW
--
In order to mail me, remove 'nospam' from the address.

Vincent GALCERAN

unread,
Mar 3, 1998, 3:00:00 AM3/3/98
to

In comp.unix.msdos Hans-Dieter Wunderlich <Hans-Dieter...@nospam.mch.sni.de> wrote:
> Howard Yen wrote:
>>
>> Does anyone know what is the limit on the number of directories within a
>> directory that UNIX can have?

> According to X/OPEN (XPG4, Version 2) there is a system constant
> LINK_MAX, restricting the number of links for a file. As each directory
> means a link to the parent directory, this also restricts the number of
> subdirectories of a given directory.
> The actual value on your system can be looked up in <limits.h>.

$grep LINK_MAX /usr/include/linux/*

/usr/include/linux/ext2_fs.h:#define EXT2_LINK_MAX 32000
/usr/include/linux/limits.h:#define LINK_MAX 127 /* # links a file may have */
/usr/include/linux/minix_fs.h:/* Not the same as the bogus LINK_MAX in <linux/limits.h>. Oh well. */
/usr/include/linux/minix_fs.h:#define MINIX_LINK_MAX 250
/usr/include/linux/sysv_fs.h:#define XENIX_LINK_MAX 126 /* ?? */
/usr/include/linux/sysv_fs.h:#define SYSV_LINK_MAX 126 /* 127? 251? */
/usr/include/linux/sysv_fs.h:#define COH_LINK_MAX 10000 /* max number of hard links to an inode */


Bob Goudreau

unread,
Mar 3, 1998, 3:00:00 AM3/3/98
to

Hans-Dieter Wunderlich <Hans-Dieter...@nospam.mch.sni.de> wrote:
> Howard Yen wrote:
>>
>> Does anyone know what is the limit on the number of directories within a
>> directory that UNIX can have?

> According to X/OPEN (XPG4, Version 2) there is a system constant
> LINK_MAX, restricting the number of links for a file. As each directory
> means a link to the parent directory, this also restricts the number of
> subdirectories of a given directory.
> The actual value on your system can be looked up in <limits.h>.

According to POSIX.1, {LINK_MAX} is not a *system* constant, but
a value which can vary from one place within the file system
hierarchy to another. If the value is constant across all pathnames
in the system, LINK_MAX is allowed to be defined in <limits.h>.
But if it can vary, LINK_MAX must be omitted from that header, and
pathconf(pathname, _PC_LINK_MAX) must be called to determine the
link limit for <pathname>.

----------------------------------------------------------------------
Bob Goudreau Data General Corporation
goud...@dg-rtp.dg.com 62 Alexander Drive
+1 919 248 6231 Research Triangle Park, NC 27709, USA

Darron Shaffer

unread,
Mar 4, 1998, 3:00:00 AM3/4/98
to
Vincent GALCERAN <galc...@fisherking.maisel.enst-bretagne.fr> writes:

> In comp.unix.msdos Hans-Dieter Wunderlich <Hans-Dieter...@nospam.mch.sni.de> wrote:
> > Howard Yen wrote:
> >>
> >> Does anyone know what is the limit on the number of directories within a
> >> directory that UNIX can have?
>
> > According to X/OPEN (XPG4, Version 2) there is a system constant
> > LINK_MAX, restricting the number of links for a file. As each directory
> > means a link to the parent directory, this also restricts the number of
> > subdirectories of a given directory.
> > The actual value on your system can be looked up in <limits.h>.
>

> $grep LINK_MAX /usr/include/linux/*
>
> /usr/include/linux/ext2_fs.h:#define EXT2_LINK_MAX 32000
> /usr/include/linux/limits.h:#define LINK_MAX 127 /* # links a file may have */
> /usr/include/linux/minix_fs.h:/* Not the same as the bogus LINK_MAX in <linux/limits.h>. Oh well. */
> /usr/include/linux/minix_fs.h:#define MINIX_LINK_MAX 250
> /usr/include/linux/sysv_fs.h:#define XENIX_LINK_MAX 126 /* ?? */
> /usr/include/linux/sysv_fs.h:#define SYSV_LINK_MAX 126 /* 127? 251? */
> /usr/include/linux/sysv_fs.h:#define COH_LINK_MAX 10000 /* max number of hard links to an inode */

However, on the first Unix (System III) that I worked on, LINK_MAX was
not a hard limit.

The rules were:

1) Adding a link.
Add one to the count unless it is already 255. Allow the new
link anyway.

2) Removing a link.
Subtract one from the count unless it is 255.

Any inode reporting a link count of 255 MIGHT have some other number
of links. If the real number is less than 255, then your next fsck
run will correct it.

I would presume modern filesystems would be at least this good.

0 new messages