summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen
Commit message (Collapse)AuthorAgeFilesLines
* MFC 271048:jhb2014-09-081-1/+1
| | | | | | | | | | | | Always seek back to the beginning of a regular directory, even if the previous seek location was 0. Without this, readdir() would see dd_loc of zero and call getdirentries() which would start reading entries at the current seek location of the directory ignoring the first batch of entries. Also, rewinddir() should always seek so that it reads the directory from the beginning to get updated entries. PR: 192935 Approved by: re (gjb)
* MFC 268531,269079,269204:jhb2014-08-147-193/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix various edge cases with rewinddir(), seekdir(), and telldir(): - In the unionfs case, opendir() and fdopendir() read the directory's full contents and cache it. This cache is not refreshed when rewinddir() is called, so rewinddir() will not notice updates to a directory. Fix this by splitting the code to fetch a directory's contents out of __opendir_common() into a new _filldir() function and call this from rewinddir() when operating on a unionfs directory. - If rewinddir() is called on a directory opened with fdopendir() before any directory entries are fetched, rewinddir() will not adjust the seek location of the backing file descriptor. If the file descriptor passed to fdopendir() had a non-zero offset, the rewinddir() will not rewind to the beginning. Fix this by always seeking back to 0 in rewinddir(). This means the dd_rewind hack can also be removed. - Add missing locking to rewinddir() - POSIX says that passing a location returned by telldir() to seekdir() after an intervening call to rewinddir() is undefined, so reclaim any pending telldir() cookies in the directory when rewinddir() is called. - If telldir() is called immediately after a call to seekdir(), POSIX requires the return value of telldir() to equal the value passed to seekdir(). The current seekdir code with SINGLEUSE enabled breaks this case as each call to telldir() allocates a new cookie. Instead, remove the SINGLEUSE code and change telldir() to look for an existing cookie for the directory's current location rather than always creating a new cookie. PR: 121656
* MFC 264161: Handle the fact that the getlogin_basic() function can returnmarcel2014-08-031-3/+8
| | | | | | a 0 status with a NULL pointer for the login name (result). Obtained from: Juniper Networks, Inc.
* MFC r268642:pfg2014-07-212-19/+8
| | | | | | | | | | | | | | | | | | | | libc/gen: small updates to code originating at OpenBSD arc4random.c - CVS rev. 1.22 Change arc4random_uniform() to calculate ``2**32 % upper_bound'' as ``-upper_bound % upper_bound''. Simplifies the code and makes it the same on both ILP32 and LP64 architectures, and also slightly faster on LP64 architectures by using a 32-bit remainder instead of a 64-bit remainder. - CVS rev. 1.23 Spacing readpassphrase.c -CVS rev. v 1.24 most obvious unsigned char casts for ctype Obtained from: OpenBSD
* MFC r268467:kib2014-07-161-3/+9
| | | | Implement sysconf(_SC_GETGR_R_SIZE_MAX) and sysconf(_SC_GETPW_R_SIZE_MAX).
* MFC r261140:pluknet2014-06-271-1/+2
| | | | Add MLINK for fdclosedir.3 to directory.3 and sort fdopendir(3) entry.
* MFC r260913,266895:nwhitehorn2014-06-081-0/+35
| | | | | | | | | | Add a new flag to /etc/ttys: onifconsole. This is equivalent to "on" if the device is an active kernel console and "off" otherwise. This is designed to allow serial-booting x86 systems to provide a login prompt on the serial line by default without providing one on all systems by default. Set this flag on x86 systems for ttyu0. Comments and suggestions by: grehan, dteske, jilles
* MFC r265847:kib2014-05-171-29/+36
| | | | | | Fix sem_unlink(3) to properly invalidate the semaphores name cache. PR: standards/189353
* MFC r265845:kib2014-05-171-2/+2
| | | | Style.
* MFC r262872: fts: Don't abort if an empty pathname is given.jilles2014-04-051-5/+1
| | | | | | | | | | Make fts_open(3) treat an empty pathname like any other pathname that cannot be lstatted because of [ENOENT]. It is rather confusing if rm -rf file1 "" file2 does not remove file1 and file2. PR: bin/187264
* MFC r263107:davidxu2014-03-171-0/+1
| | | | | | | To avoid missing a chance to cancel thread, call _pthread_testcancel at the beginning of _sem_timedwait. Submitted by: Eric van Gyzen < eric at vangyzen dot net >
* MFC r261859: fts: Fix double-free with conflicting concurrent modifications.jilles2014-03-071-4/+8
| | | | | | | If rare conditions such as concurrent conflicting manipulation of the filesystem occur, fts_read() frees the current FTSENT without adjusting the pointers in the FTS accordingly. A later fts_close() then frees the same FTSENT again.
* MFC r261080:kib2014-02-061-1/+11
| | | | | | | | | The posix_fallocate(2) syscall should return error number on error, without modifying errno. MFC r261290: The posix_madvise(3) and posix_fadvise(2) should return error on failure, same as posix_fallocate(2).
* Merge r257633:pjd2013-11-062-0/+120
| | | | | | | | | | - Add manual pages for capability rights (rights(4)), cap_rights_init(3) family of functions and cap_rights_get(3) function. - Update remaining Capsicum-related manual pages. Sponsored by: The FreeBSD Foundation Reviewed by: bdrewery Approved by: re (glebius)
* Merge r256537 from head:glebius2013-10-291-0/+11
| | | | | | | | | | Make getutxent(3) more robust against bad utx.log files. Whenever we read zeroes, don't stop processing the file, but read until its end or valid data. In collaboration with: ed Approved by: re (kib)
* Consistently reference file descriptors as "fd". 55 other manpagesbdrewery2013-09-121-6/+6
| | | | | | | | used "fd", while these used "d" and "filedes". MFC after: 1 week Approved by: gjb Approved by: re (delphij)
* Document SIGLIBRT in signal(3); take a stab at the signal description asrwatson2013-09-031-0/+1
| | | | | | the original committer didn't provide one. MFC after: 3 days
* libc: Always use our own copy of sys_errlist and sys_nerr (.so only).jilles2013-08-311-0/+6
| | | | | | | | | | | | | | | This ensures strerror() and friends continue to work correctly even if a (non-PIE) executable linked against an older libc imports sys_errlist (which causes sys_errlist to refer to the executable's copy with a size fixed when that executable was linked). The executable's use of sys_errlist remains broken because it uses the current value of sys_nerr and may access past the bounds of the array. Different from the message "Using sys_errlist from executables is not ABI-stable" on freebsd-arch, this change does not affect the static library. There seems no reason to prevent overriding the error messages in the static library.
* wordexp(): Avoid leaking the pipe file descriptors to a parallel fork/exec.jilles2013-08-271-4/+4
| | | | This uses the new pipe2() system call added on May 1 (r250159).
* Expand the use of stat(2) flags to allow storing some Windows/DOSken2013-08-211-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and CIFS file attributes as BSD stat(2) flags. This work is intended to be compatible with ZFS, the Solaris CIFS server's interaction with ZFS, somewhat compatible with MacOS X, and of course compatible with Windows. The Windows attributes that are implemented were chosen based on the attributes that ZFS already supports. The summary of the flags is as follows: UF_SYSTEM: Command line name: "system" or "usystem" ZFS name: XAT_SYSTEM, ZFS_SYSTEM Windows: FILE_ATTRIBUTE_SYSTEM This flag means that the file is used by the operating system. FreeBSD does not enforce any special handling when this flag is set. UF_SPARSE: Command line name: "sparse" or "usparse" ZFS name: XAT_SPARSE, ZFS_SPARSE Windows: FILE_ATTRIBUTE_SPARSE_FILE This flag means that the file is sparse. Although ZFS may modify this in some situations, there is not generally any special handling for this flag. UF_OFFLINE: Command line name: "offline" or "uoffline" ZFS name: XAT_OFFLINE, ZFS_OFFLINE Windows: FILE_ATTRIBUTE_OFFLINE This flag means that the file has been moved to offline storage. FreeBSD does not have any special handling for this flag. UF_REPARSE: Command line name: "reparse" or "ureparse" ZFS name: XAT_REPARSE, ZFS_REPARSE Windows: FILE_ATTRIBUTE_REPARSE_POINT This flag means that the file is a Windows reparse point. ZFS has special handling code for reparse points, but we don't currently have the other supporting infrastructure for them. UF_HIDDEN: Command line name: "hidden" or "uhidden" ZFS name: XAT_HIDDEN, ZFS_HIDDEN Windows: FILE_ATTRIBUTE_HIDDEN This flag means that the file may be excluded from a directory listing if the application honors it. FreeBSD has no special handling for this flag. The name and bit definition for UF_HIDDEN are identical to the definition in MacOS X. UF_READONLY: Command line name: "urdonly", "rdonly", "readonly" ZFS name: XAT_READONLY, ZFS_READONLY Windows: FILE_ATTRIBUTE_READONLY This flag means that the file may not written or appended, but its attributes may be changed. ZFS currently enforces this flag, but Illumos developers have discussed disabling enforcement. The behavior of this flag is different than MacOS X. MacOS X uses UF_IMMUTABLE to represent the DOS readonly permission, but that flag has a stronger meaning than the semantics of DOS readonly permissions. UF_ARCHIVE: Command line name: "uarch", "uarchive" ZFS_NAME: XAT_ARCHIVE, ZFS_ARCHIVE Windows name: FILE_ATTRIBUTE_ARCHIVE The UF_ARCHIVED flag means that the file has changed and needs to be archived. The meaning is same as the Windows FILE_ATTRIBUTE_ARCHIVE attribute, and the ZFS XAT_ARCHIVE and ZFS_ARCHIVE attribute. msdosfs and ZFS have special handling for this flag. i.e. they will set it when the file changes. sys/param.h: Bump __FreeBSD_version to 1000047 for the addition of new stat(2) flags. chflags.1: Document the new command line flag names (e.g. "system", "hidden") available to the user. ls.1: Reference chflags(1) for a list of file flags and their meanings. strtofflags.c: Implement the mapping between the new command line flag names and new stat(2) flags. chflags.2: Document all of the new stat(2) flags, and explain the intended behavior in a little more detail. Explain how they map to Windows file attributes. Different filesystems behave differently with respect to flags, so warn the application developer to take care when using them. zfs_vnops.c: Add support for getting and setting the UF_ARCHIVE, UF_READONLY, UF_SYSTEM, UF_HIDDEN, UF_REPARSE, UF_OFFLINE, and UF_SPARSE flags. All of these flags are implemented using attributes that ZFS already supports, so the on-disk format has not changed. ZFS currently doesn't allow setting the UF_REPARSE flag, and we don't really have the other infrastructure to support reparse points. msdosfs_denode.c, msdosfs_vnops.c: Add support for getting and setting UF_HIDDEN, UF_SYSTEM and UF_READONLY in MSDOSFS. It supported SF_ARCHIVED, but this has been changed to be UF_ARCHIVE, which has the same semantics as the DOS archive attribute instead of inverse semantics like SF_ARCHIVED. After discussion with Bruce Evans, change several things in the msdosfs behavior: Use UF_READONLY to indicate whether a file is writeable instead of file permissions, but don't actually enforce it. Refuse to change attributes on the root directory, because it is special in FAT filesystems, but allow most other attribute changes on directories. Don't set the archive attribute on a directory when its modification time is updated. Windows and DOS don't set the archive attribute in that scenario, so we are now bug-for-bug compatible. smbfs_node.c, smbfs_vnops.c: Add support for UF_HIDDEN, UF_SYSTEM, UF_READONLY and UF_ARCHIVE in SMBFS. This is similar to changes that Apple has made in their version of SMBFS (as of smb-583.8, posted on opensource.apple.com), but not quite the same. We map SMB_FA_READONLY to UF_READONLY, because UF_READONLY is intended to match the semantics of the DOS readonly flag. The MacOS X code maps both UF_IMMUTABLE and SF_IMMUTABLE to SMB_FA_READONLY, but the immutable flags have stronger meaning than the DOS readonly bit. stat.h: Add definitions for UF_SYSTEM, UF_SPARSE, UF_OFFLINE, UF_REPARSE, UF_ARCHIVE, UF_READONLY and UF_HIDDEN. The definition of UF_HIDDEN is the same as the MacOS X definition. Add commented-out definitions of UF_COMPRESSED and UF_TRACKED. They are defined in MacOS X (as of 10.8.2), but we do not implement them (yet). ufs_vnops.c: Add support for getting and setting UF_ARCHIVE, UF_HIDDEN, UF_OFFLINE, UF_READONLY, UF_REPARSE, UF_SPARSE, and UF_SYSTEM in UFS. Alphabetize the flags that are supported. These new flags are only stored, UFS does not take any action if the flag is set. Sponsored by: Spectra Logic Reviewed by: bde (earlier version)
* Implement fdclosedir(3) function, which is equivalent to the closedir(3)pjd2013-08-183-3/+24
| | | | | | | function, but returns directory file descriptor instead of closing it. Submitted by: Mariusz Zaborski <oshogbo@FreeBSD.org> Sponsored by: Google Summer of Code 2013
* Remove redundant space.pjd2013-08-181-1/+1
|
* dup3(3): Replace copyright notice.jilles2013-08-181-8/+4
| | | | | | | Although I copied dup(2) to create dup3(3), I removed almost all the non-boilerplate, so dup3(3) is copyright me. Reported by: bjk
* libc: Access _logname_valid more efficiently.jilles2013-08-171-1/+1
| | | | | | | | | | | The variable _logname_valid is not exported via the version script; therefore, change C and i386/amd64 assembler code to remove indirection (which allowed interposition). This makes the code slightly smaller and faster. Also, remove #define PIC_GOT from i386/amd64 in !PIC mode. Without PIC, there is no place containing the address of each variable, so there is no possible definition for PIC_GOT.
* Add man page dup3(3).jilles2013-08-162-0/+121
|
* Add dup3(), based on F_DUP2FD and F_DUP2FD_CLOEXEC fcntls.jilles2013-08-163-0/+61
| | | | | | | | I removed functionality not proposed for POSIX in Austin group issue #411. A man page (my own) and test cases will follow in later commits. PR: 176233 Submitted by: Jukka Ukkonen
* According to POSIX \ in the fnmatch(3) pattern should escapeache2013-08-081-2/+0
| | | | | | | | | | any character including '\0', but our version replace escaped '\0' with '\\'. I.e. fnmatch("\\", "\\", 0) should not match while fnmatch("\\", "", 0) should (Linux and NetBSD does the same). Was vice versa. PR: 181129 MFC after: 1 week
* Remove define and documentation for vm_pageout_algorithm missed in r253587zont2013-07-261-4/+0
|
* wordexp(): Fix syntax validation for backslashes in single-quotes.jilles2013-07-231-1/+2
|
* Fix mdoc syntax.hrs2013-07-131-7/+7
| | | | Pointed out by: joeld
* Add a leaf node CTL_NET.PF_ROUTE.0.AF.NET_RT_DUMP.0.FIB. This returnshrs2013-07-121-9/+9
| | | | routing table with the specified FIB number, not td->td_proc->p_fibnum.
* libc: Access _sigintr more efficiently.jilles2013-06-302-2/+2
| | | | | The variable _sigintr is not exported via the version script; therefore, tell the compiler that no indirection (to allow interposition) is needed.
* mdoc: convert .Fd to .In, which is much nicer.joel2013-06-041-1/+1
|
* Remove the advertising clause from the Regents of the University ofemaste2013-05-281-5/+1
| | | | California's license, per the letter dated July 22, 1999.
* The getcontext() from the __fillcontextx() call in thekib2013-05-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | check_deferred_signal() returns twice, since handle_signal() emulates the return from the normal signal handler by sigreturn(2)ing the passed context. Second return is performed on the destroyed stack frame, because __fillcontextx() has already returned. This causes undefined and bad behaviour, usually the victim thread gets SIGSEGV. Avoid nested frame and the need to return from it by doing direct call to getcontext() in the check_deferred_signal() and using a new private libc helper __fillcontextx2() to complement the context with the extended CPU state if the deferred signal is still present. The __fillcontextx() is now unused, but is kept to allow older libthr.so to be used with the new libc. Mark __fillcontextx() as returning twice [1]. Reported by: pgj Pointy hat to: kib Discussed with: dim Tested by: pgj, dim Suggested by: jilles [1] MFC after: 1 week
* Update manpages for r250887.ed2013-05-211-3/+1
| | | | | | Remove the lists of unneeded header files. Requested by: eadler
* popen(): Add 'e' mode character to set close-on-exec on the new fd.jilles2013-05-202-10/+27
| | | | | | | | | | | | | | If 'e' is used, the kernel must support the recently added pipe2() system call. The use of pipe2() with O_CLOEXEC also fixes race conditions between concurrent popen() calls from different threads, even if the close-on-exec flag on the fd of the returned FILE is later cleared (because popen() closes all file descriptors from earlier popen() calls in the child process). Therefore, this approach should be used in all cases when pipe2() can be assumed present. The old version of popen() rejects "re" and "we" but treats "r+e" like "r+".
* Typo.pluknet2013-05-121-1/+1
|
* posix_spawn_file_actions_adddup2(3): Document difference with dup2().jilles2013-05-091-2/+23
| | | | | | | | The ability to clear a file descriptor's close-on-exec flag via posix_spawn_file_actions_adddup2() is in fact proposed in Austin Group issue #411. MFC after: 1 week
* posix_spawn_file_actions_addopen(3): Correct error for bad file descriptor.jilles2013-05-091-2/+2
| | | | | | | | As per POSIX.1-2008, posix_spawn_file_actions_add* return [EBADF] if a file descriptor is negative, not [EINVAL]. The bug was only in the manual page; the code is correct. MFC after: 1 week
* wordexp(): Simplify code by deferring work to sh.jilles2013-05-091-13/+3
|
* POSIX 1003.1-2008: add ENOTRECOVERABLE, EOWNERDEAD errnos.pluknet2013-05-041-0/+2
|
* sysconf(3): Correct the description of _SC_OPEN_MAX.jilles2013-04-261-2/+2
| | | | | Reported by: bde MFC after: 1 week
* - sl_find does not modify 'name'eadler2013-04-232-2/+2
| | | | | | | | - make the prototype of sl_find match NetBSD Reviewed by: jilles Approved by: cperciva (mentor) MFC After: 3 days
* Switch from K&R prototypes to modern Ceadler2013-04-231-10/+4
| | | | | | Reviewed by: jilles Approved by: cperciva (mentor) MFC After: 3 days
* pututxline: Don't set errno=0 in subfunctions.jilles2013-04-171-4/+8
| | | | | | | | | | The functions utx_active_add(), utx_active_remove(), utx_lastlogin_add() and utx_log_add() set errno to 0 if they are successful. This not only violates POSIX if pututxline() is successful, but may also overwrite a valid error with 0 if, for example, utx_lastlogin_add() fails while utx_log_add() succeeds. Reviewed by: ed
* mdoc: remove superfluous paragraph macro.joel2013-04-161-1/+0
|
* - Document that sem_wait() can fail with EINTR if it is interrupted by ajhb2013-04-161-1/+9
| | | | | | | | signal. - Fix the old ksem implementation for POSIX semaphores to not restart sem_wait() or sem_timedwait() if interrupted by a signal. MFC after: 1 week
* Spelling correctionemaste2013-04-111-1/+1
|
* wordexp(): Remove wrong IFS usage.jilles2013-04-011-4/+1
| | | | | | | | | | | Words in shell script are separated by spaces or tabs independent of the value of IFS. The value of IFS is only relevant for the result of substitutions. Therefore, there should be a space between 'wordexp' and the words to be expanded, not an IFS character. Paranoia might dictate that the shell ignore IFS from the environment (even though our sh currently uses it), so do not depend on it in the new test case.
OpenPOWER on IntegriCloud