Date: Sun, 30 Nov 1997 14:49:30 +0200 (IST) From: Eli Zaretskii To: DJ Delorie cc: djgpp-workers AT delorie DOT com Subject: Patches for fpathconf and docs for pathconf Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk I became tired of looking into the sources and a bunch of headers every time I needed to know what exactly does `pathconf' return in its DJGPP incarnation. So here are the docs patches that tell the full story. This also fixes `fpathconf' so it reports the values from the filesystem where the handle belongs, if that can be determined by `fstat'. *** src/libc/posix/unistd/pathconf.t~0 Mon Jul 10 05:42:40 1995 --- src/libc/posix/unistd/pathconf.txh Sat Nov 29 15:30:22 1997 *************** *** 10,22 **** @subheading Description ! Returns configuration information on the filesystem that the ! open file resides on. @xref{pathconf}. @subheading Return Value ! The configuration value, which are currently independent of the filesystem ! that the file is on. @c ---------------------------------------------------------------------- @node pathconf, posix --- 10,23 ---- @subheading Description ! Returns configuration information on the filesystem that the open file ! resides on. @xref{pathconf}. If the filesystem cannot be determined ! from the file handle @var{fd} (e.g., for character devices), ! @code{fpathconf} will return the info for the current drive. @subheading Return Value ! The configuration value; for details, see @ref{pathconf}. @c ---------------------------------------------------------------------- @node pathconf, posix *************** *** 37,77 **** @item _PC_LINK_MAX ! The maximum number of directory entries that can refer to a single real file. @item _PC_MAX_CANON ! The maximum number of bytes in an editable input line. @item _PC_MAX_INPUT ! The maximum number of bytes in a non-editable input line. @item _PC_NAME_MAX ! The maximum length of an individual file name. @item _PC_PATH_MAX ! The maximum length of a complete path name. @item _PC_PIPE_BUF ! The size of a pipe's internal buffer. @item _PC_CHOWN_RESTRICTED ! If non-zero, only privileged user can chown() files, otherwise anyone may ! give away files. @item _PC_NO_TRUNC ! If false filenames longer than @code{_PC_NAME_MAX} are truncated, otherwise ! an error occurs if you use longer names. @item _PC_VDISABLE ! A character to use to disable tty special characters. @end table --- 38,92 ---- @item _PC_LINK_MAX ! The maximum number of directory entries that can refer to a single real ! file. Always 1 in DJGPP. @item _PC_MAX_CANON ! The maximum number of bytes in an editable input line. In DJGPP, this ! is 126 (DOS restriction). @item _PC_MAX_INPUT ! The maximum number of bytes in a non-editable input line. Also 126 in ! DJGPP. @item _PC_NAME_MAX ! The maximum length of an individual file name. If the filesystem where ! @var{filename} resides supports long file names, the result is whatever ! @code{_get_volume_info} returns (usually 255); otherwise 12 will be ! returned. @xref{_use_lfn}. @item _PC_PATH_MAX ! The maximum length of a complete path name. If the filesystem where ! @var{filename} resides supports long file names, the result is whatever ! @code{_get_volume_info} returns (usually 260); otherwise 80 will be ! returned. @xref{_use_lfn}. @item _PC_PIPE_BUF ! The size of a pipe's internal buffer. In DJGPP, this returns 512. @item _PC_CHOWN_RESTRICTED ! If non-zero, only priviledged user can change the ownership of files by ! calling @code{chown}, otherwise anyone may give away files. The DJGPP ! version always returns zero, since MS-DOS files can be freely given ! away. @item _PC_NO_TRUNC ! If zero is returned, filenames longer than what ! @w{@code{pathconf (filename, _PC_NAME_MAX)}} returns are truncated, ! otherwise an error occurs if you use longer names. In DJGPP, this ! returns 0, since DOS always silently truncates long names. @item _PC_VDISABLE ! A character to use to disable tty special characters. DJGPP currently ! doesn't support special characters, so this returns -1. @end table *** src/libc/posix/unistd/fpathcon.c~0 Sat Apr 1 21:24:04 1995 --- src/libc/posix/unistd/fpathcon.c Sat Nov 29 15:25:42 1997 *************** *** 1,11 **** /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include #include - /* ARGSUSED */ long fpathconf(int fildes, int name) { ! return pathconf("/", name); } --- 1,24 ---- + /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include #include + #include long fpathconf(int fildes, int name) { ! static char root_path[] = "/"; ! struct stat st_buf; ! char fs_root[4]; ! char *p = root_path; ! ! /* `fstat' returns non-negative `st_dev' for regular disk files. */ ! if (fstat(fildes, &st_buf) == 0 && st_buf.st_dev >= 0) ! { ! fs_root[0] = 'A' + st_buf.st_dev; ! strcpy(fs_root + 1, ":\\"); ! p = fs_root; ! } ! return pathconf(p, name); }