From owner-freebsd-questions Fri Oct 5 15:15:41 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mailc.telia.com (mailc.telia.com [194.22.190.4]) by hub.freebsd.org (Postfix) with ESMTP id 4EB9637B407 for ; Fri, 5 Oct 2001 15:15:36 -0700 (PDT) Received: from d1o913.telia.com (d1o913.telia.com [195.252.44.241]) by mailc.telia.com (8.11.6/8.11.6) with ESMTP id f95MFYH00276 for ; Sat, 6 Oct 2001 00:15:34 +0200 (CEST) Received: from ertr1013.student.uu.se (h185n2fls20o913.telia.com [212.181.163.185]) by d1o913.telia.com (8.8.8/8.8.8) with SMTP id AAA17623 for ; Sat, 6 Oct 2001 00:15:34 +0200 (CEST) Received: (qmail 75598 invoked by uid 1001); 5 Oct 2001 22:15:33 -0000 Date: Sat, 6 Oct 2001 00:15:33 +0200 From: Erik Trulsson To: "Dreamtime.net Inc." Cc: questions@freebsd.org Subject: Re: Directory Limit Question Message-ID: <20011006001533.A75578@student.uu.se> Mail-Followup-To: "Dreamtime.net Inc." , questions@freebsd.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.22.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Oct 05, 2001 at 02:47:56PM -0700, Dreamtime.net Inc. wrote: > How many subdirectories might be created in a directory on a > local drive (freebsd-4.2). I have put 32765 subdirectories and > when I try to create another one, the system says: > > bash$ ls | wc > 32765 32767 288325 > bash$ mkdir anotherone > mkdir: anotherone: Too many links > bash$ > > Is there is any "official" limit, is there any way to overcome it? You just found the limit and not really. From /usr/include/sys/syslimits.h #define LINK_MAX 32767 /* max file link count */ There can be at most 32767 hard links to any given inode (this is because a signed 16-bit field in teh inode is used to keep track of this.) Since every directory contains a hard link ('..') to its parent and since there are always at least two links to a directory (the directory's link to itelf ('.') and of course the entry in the parent directory this means that the maximum number of subdirectories in a directory is 32767-2 = 32765. Changing this limit to something larger than 16 bits would require rebuilding the filesystem after modifying the kernel appropriately and would almost certainly break lots of things. Changing the counter from signed to unsigned (and changing LINK_MAX to 65535) might work but I wouldn't recommend doing that unless you know what you are doing since the chances are fairly high that something will break. Question: Why would you want to have that many subdirectories ? I can't really think of any compelling reasons. -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message