Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Dec 2016 12:07:28 -0500
From:      Anton Yuzhaninov <citrin+bsd@citrin.ru>
To:        freebsd-net@freebsd.org
Subject:   Re: question about fopen fd limit
Message-ID:  <db68aff8-d23e-7e59-22ac-69dcf2a86c3f@citrin.ru>
In-Reply-To: <2016122223570929089978@corp.netease.com>
References:  <2016122223570929089978@corp.netease.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 12/22/16 10:57, 盛慧华 wrote:
>   and even in BSD 10 , it seems this short limit still there , but other OS as debian , FILE strucnt's fileno is a int .

  * Certain members of __sFILE are accessed directly via macros or
  * inline functions.  To preserve ABI compat, these members must not
  * be disturbed.  These members are marked below with (*).
  */
struct __sFILE {
         ....
         short   _file;          /* (*) fileno, if Unix descriptor, else 
-1 */

If _file will be changed to int it will break existing binaries on upgrade.
Other OSes are more liberal in breaking compatibility.

>
>   we found an unoffical patch easily change this fileno to unsigned , but we are a very stready project, we can't afford the risk
> to use an unoffical patch.

It is better change this field to int and rebuild all binaries (base 
system and ports). But if you mix binaries from patched and unpatched 
tree, system will be broken.

Other options are:

- use open instead fopen, write instead fwrite e.t.c. For big 
applications it is a lot of work, but almost all scalable applications 
don't use f* functions to work with files.

- find some library for file io with similar interface or write one.

- port musl libc to FreeBSD and link your application statically with 
musl (not an option really, to much work).



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?db68aff8-d23e-7e59-22ac-69dcf2a86c3f>