Linux path name and file name maximum length limit

Source: Internet
Author: User

The UNIX standard describes the path name and file name maximum length limit, but its upper limit is too small for the actual application, and Linux increases the limit in its implementation, which is explained in Linux /usr/include/linux/limits.h . , specifically as follows:

1 #ifndef _linux_limits_h2 #define_linux_limits_h3 4 #defineNr_open 10245 6 #defineNgroups_max 65536/* Supplemental Group IDs is available */7 #defineArg_max 131072/* # bytes of args + environ for exec () */8 #defineLink_max 127/* # Links a file may have */9 #defineMax_canon 255/* Size of the canonical input queue */Ten #defineMax_input 255/* Size of the type-ahead buffer */ One #defineName_max 255/* # file name Max characters */ A #definePath_max 4096/* # relative pathname maximum number of characters */ - #definePIPE_BUF 4096/* # bytes in atomic write to a pipe */ - #defineXattr_name_max 255/* # chars in an extended attribute NAME */ the #defineXattr_size_max 65536/* SIZE of an extended attribute value (64k) */ - #defineXattr_list_max 65536/* Size of Extended attribute NameList (64k) */ -  - #defineRtsig_max 32 +  - #endif

The 11th and 12th lines of the above-mentioned file contents describe the maximum length of the filename and relative path name, respectively. It is necessary to note that the character refers to ASCII characters, and if it is a Chinese character or other language, it is dependent on the encoding.

The above header files can be included in the program and then referenced directly, these values can also be queried using the pathconf () function, and the parameters of the pathconf () function can be found in the table in the article:UNIX Environment Advanced Programming Chapter 2nd UNIX standards and implementation

A simple example demonstration is as follows:

#include <iostream><unistd.h>usingnamespace  std; int Main () {    << pathconf ("/", _pc_name_max) << Endl; return 0 ;}

Linux path name and file name maximum length limit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.