From owner-freebsd-net@freebsd.org Thu Dec 22 17:07:34 2016 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40FF0C8D4D8 for ; Thu, 22 Dec 2016 17:07:34 +0000 (UTC) (envelope-from citrin+bsd@citrin.ru) Received: from hz.citrin.ru (hz.citrin.ru [IPv6:2a01:4f8:d16:10c3::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0C0B9ACE for ; Thu, 22 Dec 2016 17:07:33 +0000 (UTC) (envelope-from citrin+bsd@citrin.ru) Received: from x220.lan (c-24-60-168-172.hsd1.ct.comcast.net [24.60.168.172]) by hz.citrin.ru (Postfix) with ESMTPSA id C05FA286A66 for ; Thu, 22 Dec 2016 17:07:30 +0000 (UTC) Subject: Re: question about fopen fd limit To: freebsd-net@freebsd.org References: <2016122223570929089978@corp.netease.com> From: Anton Yuzhaninov Message-ID: Date: Thu, 22 Dec 2016 12:07:28 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <2016122223570929089978@corp.netease.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrin.ru; s=s0; t=1482426451; bh=FkhJ/6OP9edZHyB8kpUeBjgeJAtXYYMNcEpM5L3Za2c=; h=Subject:To:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=Xq9wC0fJ5UddlBCOachU5QaODlPej516ALu05W/TMxfCfqUv/2rlpezyqwzM3+xY4fX7zFjDTnIj5lp5ucCv9zTE9Ri02FdF8OauPHTapRke9yVd3eFtp+Zm2KbQ2+Y0ppKzQLDNt6AvPP21LZ4sd+VuCeqiytJge5BXfaBf9C4= X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Dec 2016 17:07:34 -0000 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).