question about fopen fd limit
Anton Yuzhaninov
citrin+bsd at citrin.ru
Thu Dec 22 17:07:34 UTC 2016
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).
More information about the freebsd-net
mailing list