Commit Graph

6235 Commits

Author SHA1 Message Date
Edward Tomasz Napierala
ec71a417a8 Add missing MLINKS for acl_{get,set}_link_fd(3).
Approved by:	re (kib)
2009-07-14 19:37:53 +00:00
Edward Tomasz Napierala
e64e7115aa Move msg{snd,recv,get,ctl} manual pages from section 3 to 2.
Approved by:	re (kib)
2009-07-13 12:53:43 +00:00
Ed Schouten
77822acff7 Fix fwrite() to return 0 when size or nmemb are zero.
Right now nmemb is returned when size is 0. In newer versions of the
standards, it is explicitly required that fwrite() should return 0.

Submitted by:	Christoph Mallon
Approved by:	re (kib)
2009-07-12 13:09:43 +00:00
Edward Tomasz Napierala
c38898116a There is an optimization in chmod(1), that makes it not to call chmod(2)
if the new file mode is the same as it was before; however, this
optimization must be disabled for filesystems that support NFSv4 ACLs.
Chmod uses pathconf(2) to determine whether this is the case - however,
pathconf(2) always follows symbolic links, while the 'chmod -h' doesn't.

This change adds lpathconf(3) to make it possible to solve that problem
in a clean way.

Reviewed by:	rwatson (earlier version)
Approved by:	re (kib)
2009-07-08 15:23:18 +00:00
Pawel Jakub Dawidek
69a789b985 - Don't suggest opening file for writing in preparation for fexecve(2).
- execve(2)/fexecve(2) won't return ETXTBSY if file is open for reading.

Approved by:	re (kib)
2009-07-05 20:20:09 +00:00
Edward Tomasz Napierala
bc8036862b Make it clear where to look for for protocol-specific socket options.
Reviewed by:	rwatson
Approved by:	re (kib)
2009-06-30 20:53:56 +00:00
Konstantin Belousov
8c8484d103 Make the structure definitions in the man pages match the real code, and
remove no longer valid caution.

Approved by:	re (kensmith)
2009-06-29 18:54:17 +00:00
Alexander Kabaev
d48890cfb8 Back out previous revision until better tested fix is ready.
Approved by: re (impliciti, by approving previos check-in)
2009-06-29 01:33:59 +00:00
Alexander Kabaev
a162c9ae9c Eliminate .text relocations in shared libraries compiled with stack protector.
Use libssp_nonshared library to pull __stack_chk_fail_local symbol into
each library that needs it instead of pulling it from libc. GCC generates
local calls to this function which result in absolute relocations put into
position-independent code segment, making dynamic loader do extra work everys
time given shared library is being relocated and making affected text pages
non-shareable.

Reviewed by:        kib
Approved by:        re (kensmith)
2009-06-28 23:51:39 +00:00
Xin LI
40523da708 Implement %z for strptime.
PR:		kern/63064
Submitted by:	Stefan `Sec` Zehl <sec 42 org> (with some small changes)
MFC after:	1 month
2009-06-25 23:59:23 +00:00
Edward Tomasz Napierala
c3380d406a Fix acl_set_fd(3) and acl_get_fd(3) for cases where the kernel doesn't know
anything about _PC_ACL_NFS4.
2009-06-25 20:57:53 +00:00
Edward Tomasz Napierala
b372d0d8bc Manual page tweaks. 2009-06-25 16:34:29 +00:00
Edward Tomasz Napierala
85e71e24c5 Fix c194955 - somehow I managed all the new files, tripling their
contents.
2009-06-25 13:08:02 +00:00
Edward Tomasz Napierala
ca48e73a18 Bump manual page timestamps. 2009-06-25 12:53:50 +00:00
Edward Tomasz Napierala
aa015c8e4a Add NFSv4 ACL support to libc.
This adds the following functions to the acl(3) API: acl_add_flag_np,
acl_clear_flags_np, acl_create_entry_np, acl_delete_entry_np,
acl_delete_flag_np, acl_get_extended_np, acl_get_flag_np, acl_get_flagset_np,
acl_set_extended_np, acl_set_flagset_np, acl_to_text_np, acl_is_trivial_np,
acl_strip_np, acl_get_brand_np.  Most of them are similar to what Darwin
does.  There are no backward-incompatible changes.

Approved by:    rwatson@
2009-06-25 12:46:59 +00:00
Xin LI
5f4faf74cb Lock around access to nc_file and netconfig_info ("ni"). The RPC
part of libc is still not thread safe but this would at least
reduce the problems we have.

PR:		threads/118544
Submitted by:	Changming Sun <snnn119 gmail com>
MFC after:	2 weeks
2009-06-24 23:17:16 +00:00
John Baldwin
b648d4806b Change the ABI of some of the structures used by the SYSV IPC API:
- The uid/cuid members of struct ipc_perm are now uid_t instead of unsigned
  short.
- The gid/cgid members of struct ipc_perm are now gid_t instead of unsigned
  short.
- The mode member of struct ipc_perm is now mode_t instead of unsigned short
  (this is merely a style bug).
- The rather dubious padding fields for ABI compat with SV/I386 have been
  removed from struct msqid_ds and struct semid_ds.
- The shm_segsz member of struct shmid_ds is now a size_t instead of an
  int.  This removes the need for the shm_bsegsz member in struct
  shmid_kernel and should allow for complete support of SYSV SHM regions
  >= 2GB.
- The shm_nattch member of struct shmid_ds is now an int instead of a
  short.
- The shm_internal member of struct shmid_ds is now gone.  The internal
  VM object pointer for SHM regions has been moved into struct
  shmid_kernel.
- The existing __semctl(), msgctl(), and shmctl() system call entries are
  now marked COMPAT7 and new versions of those system calls which support
  the new ABI are now present.
- The new system calls are assigned to the FBSD-1.1 version in libc.  The
  FBSD-1.0 symbols in libc now refer to the old COMPAT7 system calls.
- A simplistic framework for tagging system calls with compatibility
  symbol versions has been added to libc.  Version tags are added to
  system calls by adding an appropriate __sym_compat() entry to
  src/lib/libc/incldue/compat.h. [1]

PR:		kern/16195 kern/113218 bin/129855
Reviewed by:	arch@, rwatson
Discussed with:	kan, kib [1]
2009-06-24 21:10:52 +00:00
Xin LI
47f8598e50 Update SCCS IDs for Berkeley DB 1.86 merge. 2009-06-24 01:15:10 +00:00
Xin LI
fc35a18481 style: operators should appear at the line end if we have to wrap. 2009-06-24 01:14:17 +00:00
Xin LI
eb4bd20c17 Use const instead of __const, and merge the license change from NetBSD.
Obtained from:	NetBSD
2009-06-23 23:52:12 +00:00
Edwin Groothuis
9cf330555a Remove duplicate if-statement on gmt_is_set in gmtsub().
MFC after:	1 week
2009-06-23 22:28:44 +00:00
Konstantin Belousov
c9253e931d Usermode portion of the support for swap allocation accounting:
- update for getrlimit(2) manpage;
- support for setting RLIMIT_SWAP in login class;
- addition to the limits(1) and sh and csh limit-setting builtins;
- tuning(7) documentation on the sysctls controlling overcommit.

In collaboration with:	pho
Reviewed by:	alc
Approved by:	re (kensmith)
2009-06-23 20:57:27 +00:00
Jamie Gritton
b97457e2e6 Add a limit for child jails via the "children.cur" and "children.max"
parameters.  This replaces the simple "allow.jails" permission.

Approved by:	bz (mentor)
2009-06-23 20:35:51 +00:00
Ed Schouten
dc428c2ffe Remove unneeded stdlib directories.
It's not necessary to add stdlib directories for each architecture, even
if the architecture doesn't implement any files of its own.

Submitted by:	Christoph Mallon
2009-06-23 14:11:41 +00:00
Ed Schouten
87fbd35f4f Simplify. We can just use .sinclude here.
Submitted by:	Christoph Mallon
2009-06-23 14:10:46 +00:00
Ed Schouten
e71280c7bc Remove hand-written labs/abs implementations. GCC is smart enough.
It turns out GCC generates code that's a couple of bytes big bigger, but
performs no branching whatsoever.

Submitted by:	Christoph Mallon
2009-06-23 09:04:59 +00:00
Ed Schouten
f863f9cbd9 Remove unneeded stores back into the function arguments.
Submitted by:	Christoph Mallon
2009-06-22 10:56:08 +00:00
Stanislav Sedov
c61860f8a6 - Eliminate extra subcs instruction. I have not noticed before that we
always perform substraction now, so no instruction could be rordered
  to eliminate the conditional substraction.
2009-06-21 13:15:56 +00:00
Stanislav Sedov
aa79fe245d - Fix strncmp on arm. Return 0 as result without performing the
main cycle only if the len passed is equal to 0. If end address
  overflows use last possible address as the end address.

Based on:	discussion on arm@
MFC after:	1 month
2009-06-21 12:58:56 +00:00
Brooks Davis
838d985825 Rework the credential code to support larger values of NGROUPS and
NGROUPS_MAX, eliminate ABI dependencies on them, and raise the to 1024
and 1023 respectively.  (Previously they were equal, but under a close
reading of POSIX, NGROUPS_MAX was defined to be too large by 1 since it
is the number of supplemental groups, not total number of groups.)

The bulk of the change consists of converting the struct ucred member
cr_groups from a static array to a pointer.  Do the equivalent in
kinfo_proc.

Introduce new interfaces crcopysafe() and crsetgroups() for duplicating
a process credential before modifying it and for setting group lists
respectively.  Both interfaces take care for the details of allocating
groups array. crsetgroups() takes care of truncating the group list
to the current maximum (NGROUPS) if necessary.  In the future,
crsetgroups() may be responsible for insuring invariants such as sorting
the supplemental groups to allow groupmember() to be implemented as a
binary search.

Because we can not change struct xucred without breaking application
ABIs, we leave it alone and introduce a new XU_NGROUPS value which is
always 16 and is to be used or NGRPS as appropriate for things such as
NFS which need to use no more than 16 groups.  When feasible, truncate
the group list rather than generating an error.

Minor changes:
  - Reduce the number of hand rolled versions of groupmember().
  - Do not assign to both cr_gid and cr_groups[0].
  - Modify ipfw to cache ucreds instead of part of their contents since
    they are immutable once referenced by more than one entity.

Submitted by:	Isilon Systems (initial implementation)
X-MFC after:	never
PR:		bin/113398 kern/133867
2009-06-19 17:10:35 +00:00
Brooks Davis
54404cfb13 In preparation for raising NGROUPS and NGROUPS_MAX, change base
system callers of getgroups(), getgrouplist(), and setgroups() to
allocate buffers dynamically.  Specifically, allocate a buffer of size
sysconf(_SC_NGROUPS_MAX)+1 (+2 in a few cases to allow for overflow).

This (or similar gymnastics) is required for the code to actually follow
the POSIX.1-2008 specification where {NGROUPS_MAX} may differ at runtime
and where getgroups may return {NGROUPS_MAX}+1 results on systems like
FreeBSD which include the primary group.

In id(1), don't pointlessly add the primary group to the list of all
groups, it is always the first result from getgroups().  In principle
the old code was more portable, but this was only done in one of the two
places where getgroups() was called to the overall effect was pointless.

Document the actual POSIX requirements in the getgroups(2) and
setgroups(2) manpages.  We do not yet support a dynamic NGROUPS, but we
may in the future.

MFC after:	2 weeks
2009-06-19 15:58:24 +00:00
Alexander Kabaev
e7733ffa39 Re-do r192913 in less intrusive way. Only do IP_RECVDSTADDR/IP_SENDSRCADDR
dace for UPDv4 sockets bound to INADDR_ANY. Move the code to set
IP_RECVDSTADDR/IP_SENDSRCADDR into svc_dg.c, so that both TLI and non-TLI
users will be using it.

Back out my previous commit to mountd. Turns out the problem was affecting
more than one binary so it needs to me addressed in generic rpc code in
libc in order to fix them all.

Reported by:	lstewart
Tested by:	lstewart
2009-06-18 17:10:43 +00:00
John Baldwin
8ee45544b2 Retire the unused stub for the nfsclnt() system call. 2009-06-17 18:52:42 +00:00
Ed Schouten
7c7cef7278 Add revoke(1).
While hacking on TTY code, I often miss a small utility to revoke my own
(pseudo-)terminals. This small utility is just a small wrapper around
the revoke(2) call, so you can destroy your very own login sessions.

Approved by:	re
2009-06-15 21:52:27 +00:00
John Baldwin
c4f16b69e1 Add a new 'void closefrom(int lowfd)' system call. When called, it closes
any open file descriptors >= 'lowfd'.  It is largely identical to the same
function on other operating systems such as Solaris, DFly, NetBSD, and
OpenBSD.  One difference from other *BSD is that this closefrom() does not
fail with any errors.  In practice, while the manpages for NetBSD and
OpenBSD claim that they return EINTR, they ignore internal errors from
close() and never return EINTR.  DFly does return EINTR, but for the common
use case (closing fd's prior to execve()), the caller really wants all
fd's closed and returning EINTR just forces callers to call closefrom() in
a loop until it stops failing.

Note that this implementation of closefrom(2) does not make any effort to
resolve userland races with open(2) in other threads.  As such, it is not
multithread safe.

Submitted by:	rwatson (initial version)
Reviewed by:	rwatson
MFC after:	2 weeks
2009-06-15 20:38:55 +00:00
Xin LI
dbfbdd0474 Spacing fixes. No actual change. 2009-06-09 09:02:58 +00:00
Alexander Kabaev
8a784b73d3 Do not attempt to set source address on outgoing messages
on UDP socket if we do not have a valid IP address.
2009-06-08 03:39:15 +00:00
Pawel Jakub Dawidek
2430d82448 Document EINVAL for bind(2).
Reviewed by:	rwatson
Obtained from:	SuSv3
2009-06-01 09:32:12 +00:00
Marcel Moolenaar
b6d434fc28 Use GCC's __SOFTFP__ to test whether we're being compiled
with softfloat or not. Now -msoft-float can be overridden
more easily.
2009-05-31 02:03:40 +00:00
Xin LI
5512745e3a Document how to enable strict RFC 1034 enforcements.
PR:		kern/129477
2009-05-29 07:55:44 +00:00
Xin LI
a28076c8f7 Add an option to enforce strict RFC 1034 compliance.
PR:		kern/129477
2009-05-29 07:34:54 +00:00
Zachary Loafman
fcd3177f90 Match type for socket option (in practice, unnecessary, but stylistically it's a little nicer).
Suggested by:       jilles
Approved by:        dfr (mentor)
2009-05-28 15:02:44 +00:00
Zachary Loafman
7014ae09f9 Revert unnecessary memset after calloc.
Suggested by:       jhb
Approved by:        dfr (mentor)
2009-05-28 15:02:21 +00:00
Edward Tomasz Napierala
60a8b6022d Fix off by one error in acl_create_entry(3).
Reviewed by:	rwatson@
MFC after:	2 weeks
2009-05-28 07:20:52 +00:00
Ed Schouten
3d98b75bac Rename the queue macros I introduced last year.
Last year I added SLIST_REMOVE_NEXT and STAILQ_REMOVE_NEXT, to remove
entries behind an element in the list, using O(1) time. I recently
discovered NetBSD also has a similar macro, called SLIST_REMOVE_AFTER.
In my opinion this approach is a lot better:

- It doesn't have the unused first argument of the list pointer. I added
  this, mainly because OpenBSD also had it.

- The _AFTER suffix makes a lot more sense, because it is related to
  SLIST_INSERT_AFTER. _NEXT is only used to iterate through the list.

The reason why I want to rename this now, is to make sure we don't
release a major version with the badly named macros.
2009-05-27 19:28:04 +00:00
Zachary Loafman
35941cc841 Handle UDP RPC replies correctly on a multi-homed system, in userland RPC. Corrects an issue with mountd replies to OS X.
Approved by:        dfr (mentor)
2009-05-27 17:02:15 +00:00
Zachary Loafman
6d72217368 Fix an issue when nss fallback routines are used in a multithreaded application.
Reviewed by:        bushman
Approved by:        dfr (mentor)
2009-05-27 17:01:59 +00:00
Jamie Gritton
0304c73163 Add hierarchical jails. A jail may further virtualize its environment
by creating a child jail, which is visible to that jail and to any
parent jails.  Child jails may be restricted more than their parents,
but never less.  Jail names reflect this hierarchy, being MIB-style
dot-separated strings.

Every thread now points to a jail, the default being prison0, which
contains information about the physical system.  Prison0's root
directory is the same as rootvnode; its hostname is the same as the
global hostname, and its securelevel replaces the global securelevel.
Note that the variable "securelevel" has actually gone away, which
should not cause any problems for code that properly uses
securelevel_gt() and securelevel_ge().

Some jail-related permissions that were kept in global variables and
set via sysctls are now per-jail settings.  The sysctls still exist for
backward compatibility, used only by the now-deprecated jail(2) system
call.

Approved by:	bz (mentor)
2009-05-27 14:11:23 +00:00
Edwin Groothuis
84b2ce0d42 MFV of tzcode2009h revision r192887
- Clarify the license for the tzcode: public domain

MFC after:	1 month
2009-05-27 12:18:39 +00:00
Edward Tomasz Napierala
b7014134a7 Change license to more bori^Wadul^Wcanonical.
Submitted by:	rwatson@
2009-05-26 11:42:06 +00:00
Edward Tomasz Napierala
f24f1c51d3 Improve API documentation.
Reviewed by:	rwatson (earlier version)
2009-05-23 13:51:05 +00:00
Edwin Groothuis
dfc79e892f MFV of tzcode2009e:
Upgrade of the tzcode from 2004a to 2009e.

Changes are numerous, but include...

- New format of the output of zic, which supports both 32 and 64
  bit time_t formats.

- zdump on 64 bit platforms will actually produce some output instead
  of doing nothing for a looooooooong time.

- linux_base-fX, with X >= at least 8, will work without problems related
  to the local time again.

The original patch, based on the 2008e, has been running for a long
time on both my laptop and desktop machine and have been tested by
other people.

After the installation of this code and the running of zic(8), you
need to run tzsetup(8) again to install the new datafile.

Approved by:	wollman@ for usr.sbin/zic
MFC after:	1 month
2009-05-23 06:31:50 +00:00
Edward Tomasz Napierala
ae1add4e55 Make 'struct acl' larger, as required to support NFSv4 ACLs. Provide
compatibility interfaces in both kernel and libc.

Reviewed by:	rwatson
2009-05-22 15:56:43 +00:00
Christian Brueffer
a9ffff74c5 Since audit(4) isn't based on posix1e, remove the commented out audit.h header,
xref libbsm(3).

Submitted by:	rwatson
MFC after:	3 days
2009-05-19 22:28:33 +00:00
Xin LI
718d3b2852 As the comment says, close() frees the variable, record. So we obtain
the length by evaluating the value from the copy, cbuf instead.  This
fixes a crash caused by previous commit (use-after-free)

Submitted by:	Dimitry Andric <dimitry andric com>
Pointy hat to:	delphij
2009-05-14 23:09:33 +00:00
Ed Schouten
ba521305e8 TTYs don't necessarily use /dev/ttyxx.
Submitted by:	csjp
2009-05-09 16:42:57 +00:00
Ed Schouten
46b303e83d Add tcsetsid(3).
The entire world seems to use the non-standard TIOCSCTTY ioctl to make a
TTY a controlling terminal of a session. Even though tcsetsid(3) is also
non-standard, I think it's a lot better to use in our own source code,
mainly because it's similar to tcsetpgrp(), tcgetpgrp() and tcgetsid().

I stole the idea from QNX. They do it the other way around; their
TIOCSCTTY is just a wrapper around tcsetsid(). tcsetsid() then calls
into an IPC framework.
2009-05-07 13:49:48 +00:00
Sam Leffler
f4f8f02054 revert r191633; this breaks at91 & xscale (likely all arm) 2009-05-06 01:50:04 +00:00
Ed Schouten
98669c791d Our grantpt(3) and unlockpt(3) don't comply with POSIX. 2009-05-04 18:14:45 +00:00
Ed Schouten
ab52b803a0 Fix whitespace and sorting in Symbol.map. 2009-05-04 08:06:52 +00:00
Jamie Gritton
b38ff370e4 Introduce the extensible jail framework, using the same "name=value"
interface as nmount(2).  Three new system calls are added:
* jail_set, to create jails and change the parameters of existing jails.
  This replaces jail(2).
* jail_get, to read the parameters of existing jails.  This replaces the
  security.jail.list sysctl.
* jail_remove to kill off a jail's processes and remove the jail.
Most jail parameters may now be changed after creation, and jails may be
set to exist without any attached processes.  The current jail(2) system
call still exists, though it is now a stub to jail_set(2).

Approved by:	bz (mentor)
2009-04-29 21:14:15 +00:00
Jamie Gritton
7074cfa223 With the permission of phk@ change the license on remaining jail code
to a 2 clause BSD license.

Approved by:	phk
Approved by:	bz (mentor)
2009-04-29 16:02:52 +00:00
Bruce M Simpson
6de9a4eb6b Fix an obvious bug in getsourcefilter()'s use of struct __msfilterreq;
the kernel will return in msfr_nsrcs the number of source filters
in-mode for a given multicast group.
However, the filters themselves were never copied out, as the libc
function clobbers this field with zero, causing the kernel to assume
the provided vector of struct sockaddr_storage has zero length.
This bug would only affect users of SSM multicast, which is shimmed
in 7.x.
Picked up during mtest(8) refactoring.

MFC after:	1 day
2009-04-29 09:58:31 +00:00
Olivier Houchard
8957464be7 Change the test at the beginning of strncmp(), from being if (len - 1) < 0
to if (len == 0).
The length is supposed to be unsigned, so len - 1 < 0 won't happen except
if len == 0 anyway, and it would return 0 when it shouldn't, if len was
> INT_MAX.

Spotted out by:	Channa <channa kad gmail com>
2009-04-28 19:20:13 +00:00
Edward Tomasz Napierala
5d8532a1b1 Fix typo. 2009-04-26 10:12:20 +00:00
Christian Brueffer
2a72feb42b Correct the information about when the respective functionality first
appeared in FreeBSD.

PR:		133785
Submitted by:	Ulrich Spoerlein <uqs@spoerlein.net>
MFC after:	3 days
2009-04-23 08:37:56 +00:00
Edward Tomasz Napierala
bab43bab0c There is no way for strmode(3) to append '+' if the file has ACL,
because there is no way to figure that out based on the file mode
itself.  Make the manual page match reality.
2009-04-14 11:39:56 +00:00
Robert Watson
a14e812168 Sort man page cross references by section, no need for a comma after the
last cross reference.

MFC after:	3 days
2009-04-13 18:32:26 +00:00
Ed Maste
14846f9b49 Include a space between "send" and "broadcast". 2009-04-09 20:57:35 +00:00
Edward Tomasz Napierala
5174a6a262 Add wide character variants of string manipulations routines to 'SEE ALSO'.
Approved by:	rwatson (mentor)
2009-04-07 13:42:53 +00:00
David Schultz
6685ac34d9 Return -1 instead of 0 upon reaching EOF. This is somewhat ill-advised
because it means getdelim() returns -1 for both error and EOF, and
never returns 0. However, this is what the original GNU	implementation
does, and POSIX inherited the bug.

Reported by:	marcus@
2009-04-06 13:50:04 +00:00
Konstantin Belousov
c8da4f07d7 Allow the NULL, RTLD_SELF and RTLD_NEXT handles to work with dlfunc(3).
dlfunc() called dlsym() to do the work, and dlsym() determines the dso
that originating the call by the return address. Due to this, dlfunc()
operated as if the caller is always the libc.

To fix this, move the dlfunc() to rtld, where it can call the internal
implementation of dlsym, and still correctly fetch return address.
Provide usual weak stub for the symbol from libc for static binaries.
dlfunc is put to FBSD_1.0 symver namespace in the ld.so export to
override dlfunc@FBSD_1.0 weak symbol, exported by libc.

Reported, analyzed and tested by:	Tijl Coosemans <tijl ulyssis org>
PR: standards/133339
Reviewed by:	kan
2009-04-03 19:17:23 +00:00
Xin LI
9b4dadd3e0 Properly handle malloc() failures.
PR:		bin/83338
2009-04-02 22:17:02 +00:00
Xin LI
985a73f6d3 Remove a warning which is supposed to have been removed on 20030301. 2009-04-02 21:51:54 +00:00
John Baldwin
1c52c37eae Properly update the shm_open/shm_unlink symbol versioning metadata after
these functions were moved into the kernel:
- Move the version entries from gen/ to sys/.  Since the ABI of the actual
  routines did not change, I'm still exporting them as FBSD 1.0 on purpose.
- Add FBSD-private versions for the _ and __sys_ variants.
2009-04-02 15:53:29 +00:00
Konstantin Belousov
8b61c10e48 Unconditionally build wrappers for i386_get_ioperm(), i386_set_ioperm(),
i386_get_ldt() and i386_set_ldt().

In collaboration with:	pho
Reviewed by:	jhb
2009-04-01 19:23:46 +00:00
Konstantin Belousov
b2e4ce45d9 Document RTLD_NODELETE, -z nodelete and -z origin support. 2009-04-01 14:38:20 +00:00
Hajimu UMEMOTO
bc42149220 Query DNS only once per an address family.
Obtained from:	KAME
MFC after:	2 weeks
2009-03-29 17:55:11 +00:00
Xin LI
e8ee08bad8 Add some casts to silence compiler warning about signedness. 2009-03-28 07:44:08 +00:00
Xin LI
9fc74a871c Minor changes from Berkeley DB 1.86 and further improvements from OpenBSD.
This does not include the new hash routines since they will cause problems
when reading old hash files.

Since mpool(3) has been changed, provide a compatibility shim for older
binaries.

Obtained from:	OpenBSD
2009-03-28 07:31:02 +00:00
Xin LI
73590c342a Allow O_SYNC and O_NOFOLLOW flags in dbopen().
Obtained from:	OpenBSD
2009-03-28 07:26:00 +00:00
Xin LI
6c90d46ee5 Plug memory leaks and a potential NULL dereference.
Obtained from:	OpenBSD
2009-03-28 07:20:39 +00:00
Xin LI
edcdc752ec Simplify the logic when determining whether to zero out a db file to after
open().  The previous logic only initializes the database when O_CREAT is
set, but as long as we can open and write the database, and the database
is empty, we should initialize it anyway.

Obtained from:	OpenBSD
2009-03-28 07:09:51 +00:00
Xin LI
a47fc82519 - If (keysize+datasize)%(bsize=14)==0, insertion of a `big key' would cause
an invariant (actually, an ugly hack) to fail, and all Hell would break
   loose.

   When deleting a big key, the offset of an empty page should be bsize, not
   bsize-1; otherwise an insertion into the empty page will cause the new key to
   be elongated by 1 byte.

   Make the packing more dense in a couple of cases.

 - fix NULL dereference exposed on big bsize values;

Obtained from:	NetBSD via OpenBSD
2009-03-28 06:47:05 +00:00
Xin LI
4524c90576 Avoid NULL deference which causes DEBUG1 to crash, not to print useful
information.

Obtained from:	OpenBSD
2009-03-28 06:40:48 +00:00
Xin LI
89bc741f77 - Avoid overwriting the cursor page when the cursor page becomes the
LRU page.
 - Fix for sequential retrieval failure when using large key/data pairs.

Obtained from:	OpenBSD
2009-03-28 06:38:31 +00:00
Xin LI
213bceeead Fix a crash when iterating over a hash and removing its elements.
Obtained from:	OpenBSD
2009-03-28 06:30:43 +00:00
Xin LI
3130c353f8 Only squeeze a short key/value pair onto a page with other complete key/value
pairs, not onto a page containing the end of a big pair.

Obtained from:	NetBSD via OpenBSD
2009-03-28 06:25:33 +00:00
Xin LI
b115f257ba Diff reduce against OpenBSD, no functional change. 2009-03-28 06:23:10 +00:00
Xin LI
a53e89e3a1 Return meaningful errno in overflow case; print error message to stderr
in one more case.

Obtained from:	NetBSD via OpenBSD
2009-03-28 06:12:39 +00:00
Xin LI
d3b2afad1b Use pread(2) and pwrite(2) instead of lseek(2) + read(2) / write(2).
Obtained from:	NetBSD via OpenBSD
2009-03-28 06:05:53 +00:00
Xin LI
02d7f710b8 db/btree/bt_open.c: check return value of snprintf() and return value
if the result is truncated.

db/hash/hash_page.c: use the same way to create temporary file as
bt_open.c; check snprintf() return value.

Obtained from:	OpenBSD
2009-03-28 05:57:27 +00:00
Xin LI
f60486b3ce Several signed/unsigned warning fixes. 2009-03-28 05:45:29 +00:00
Xin LI
c9f30aaaf7 When allocating memory, zero out them if we don't intend to overwrite them
all; before freeing memory, zero out them before we release it as free
heap.  This will eliminate some potential information leak issue.

While there, remove the PURIFY option.  There is a slight difference between
the new behavior and the old -DPURIFY behavior, with the latter initializes
memory with 0xff's.  The difference between old and new approach does not
generate observable difference.

Obtained from:	OpenBSD (partly).
2009-03-28 04:00:46 +00:00
Diomidis Spinellis
15ced2cfb3 Document missing requests. 2009-03-27 11:03:02 +00:00
Hajimu UMEMOTO
4d75630780 Add support for SCTP to getaddrinfo(3).
Now, getaddrinfo(3) returns two SOCK_STREAMs, IPPROTO_TCP and
IPPROTO_SCTP.  It confuses some programs.  If getaddrinfo(3) returns
IPPROTO_SCTP when SOCK_STREAM is specified by hints.ai_socktype, at
least Apache doesn't work.  So, I made getaddrinfo(3) to return
IPPROTO_SCTP with SOCK_STREAM only when IPPROTO_SCTP is specified
explicitly by hints.ai_protocol.

PR:		bin/128167
Submitted by:	Bruce Cran <bruce__at__cran.org.uk> (partly)
MFC after:	2 week
2009-03-25 16:23:43 +00:00
Alexander Leidinger
c5f562d25a Improve the German translation.
Some parts (ERANGE, ETXTBSY) triggered by Christoph Mallon.

Discussed with:	brueffer, gabor (previous version)
2009-03-25 12:36:37 +00:00
Gabor Kovesdan
fa332705da - Add Belarusian catalog
PR:		conf/133004
Submitted by:	Tatsiana Elavaya <t.elavaya@gmail.com>
2009-03-24 23:31:41 +00:00
Hajimu UMEMOTO
d53978e3c0 getaddrinfo(3) should accept numeric when ai_socktype is not
specified in hint or hints is NULL.

PR:		bin/51827
Submitted by:	Mark Andrews <marka__at__isc.org>
MFC after:	1 week
2009-03-24 17:47:24 +00:00
Xin LI
6c0af71bdc Save errno before calling _close(), which may clear it.
Obtained from:	OpenBSD
2009-03-23 23:43:07 +00:00
Xin LI
7efabbb915 use more proper format string.
Obtained from:	NetBSD via OpenBSD
2009-03-23 23:22:09 +00:00
Konstantin Belousov
2e92f03abd 7.2 will be the first release where strndup() appears.
Submitted by:	Florian Smeets <flo kasimir com>
MFC after:	3 days
2009-03-22 15:29:12 +00:00
Maxim Konovalov
30905e0ffc o Spell. 2009-03-21 10:10:33 +00:00
Gabor Kovesdan
abc2df4ae4 - Add Ukranian catalog
Submitted by:	Alex Kozlov <spam@rm-rf.kiev.ua> (via private mail)
2009-03-20 23:55:01 +00:00
Gabor Kovesdan
e5470fee62 - Fix typo
PR:		kern/132773
Reported by:	Alan R. S. Bueno <alan.bsd@gmail.com>
Submitted by:	Murilo Opsfelder <mopsfelder@gmail.com>
2009-03-18 14:33:10 +00:00
Gabor Kovesdan
3d945c9d67 - Add Brazilian Portuguese catalog [1]
- Fixes for German catalog [2]

PR:		kern/132694 [1], conf/80504 [2]
Submitted by:	Murilo Opsfelder <mopsfelder@gmail.com> [1],
		brueffer [2]
2009-03-16 16:33:08 +00:00
Gabor Kovesdan
8a6a076cb4 - Create the buildworld object directories with mtree instead of various
mkdir calls
- Remove the ugly workaroung from libc NLS, which was to create some of
  these directories
2009-03-15 13:14:06 +00:00
Gabor Kovesdan
49a33c0b43 - Fix object directory creation when running threaded buildworld 2009-03-13 22:41:30 +00:00
Gabor Kovesdan
fe73c506a4 - Reenable Native Language Support in libc. This feature was disabled due
to possible breakages in the catalog handling code.  Since then, that
  code has been replaced by the secure code from NetBSD but NLS in libc
  remained turned off.  Tests have shown that the feature is stable and
  working so we can now turn it on again.

- Add several new catalog files:
  - ca_ES.ISO8859-1
  - de_DE.ISO8859-1
  - el_GR.ISO8859-7  (by manolis@ and keramida@)
  - es_ES.ISO8859-1  (kern/123179, by carvay@)
  - fi_FI.ISO8859-1
  - fr_FR.ISO8859-1  (kern/78756, by thierry@)
  - hu_HU.ISO8859-2  (by gabor@)
  - it_IT.ISO8859-15
  - nl_NL.ISO8859-1  (corrections by rene@)
  - no_NO.ISO8859-1
  - mn_MN.UTF-8      (by ganbold@)
  - sk_SK.ISO8859-2
  - sv_SE.ISO8859-1
  (The catalogs without explicit source has been obtained from NetBSD.)

Approved by:	attilio
2009-03-13 10:40:38 +00:00
Xin LI
38f92d0c69 Reflect license change from NetBSD.
Obtained from:	NetBSD
2009-03-10 21:13:26 +00:00
Konstantin Belousov
9f960e98aa Hopefully, improve the grammar and wording in the changes to shmctl(2)
manpage and UPDATING entry 20090302.

UPDATING changes suggested by bf2006a yahoo com.
man page corrections by bde.
2009-03-05 12:04:42 +00:00
Xin LI
7ccf00df0d Our realloc(3) and reallocf(3) can handle NULL, which turns it into a
malloc(3) call, so don't test if a pointer is NULL.

Obtained from:	OpenBSD (in spirit)
2009-03-05 00:57:01 +00:00
David Schultz
09efd0ec6a Add wcpcpy(3) and wcpncpy(3). 2009-03-04 06:01:27 +00:00
David Schultz
ad760e6fc9 Add dprintf() and vdprintf() from POSIX.1-2008. Like getline(),
dprintf() is a simple wrapper around another function, so we may as
well implement it. But also like getline(), we can't prototype it by
default right now because it would break too many ports.
2009-03-04 03:38:51 +00:00
David Schultz
ce5c3df1b2 Fix a file descriptor leak in fts_child().
Obtained from:	NetBSD
2009-03-04 03:30:21 +00:00
Bruce M Simpson
1acf7fcc63 Considerably improve the wording of this man page. 2009-03-04 01:59:14 +00:00
Bruce M Simpson
0c0fdcfe15 Update copyright. 2009-03-04 01:58:48 +00:00
Xin LI
eb3144b210 Explicitly specify bit width for on-disk data structure.
Obtained from:	OpenBSD
2009-03-04 01:17:05 +00:00
Xin LI
d170190aa8 Sync license changes.
Obtained from:	NetBSD
2009-03-04 01:01:26 +00:00
Xin LI
3df1d93483 Style changes (including additional casts to shut up warnings). This
commit does not affect MD5 of object file.
2009-03-04 00:58:04 +00:00
Xin LI
4c66e4b64b Rename variable 'index' to 'idx' to avoid name collision with index(3),
this commit does not affect any object code.

Obtained from:	OpenBSD
Verified with:	md5(1)
2009-03-03 02:16:12 +00:00
Xin LI
0ac22237f1 Diff reduction against OpenBSD: ANSI'fy prototypes.
(This is part of a larger changeset which is intended to reduce diff only,
thus some prototypes were left intact since they will be changed in the
future).

Verified with:	md5(1)
2009-03-02 23:47:18 +00:00
Konstantin Belousov
65067cc8b0 Correct types of variables used to track amount of allocated SysV shared
memory from int to size_t. Implement a workaround for current ABI not
allowing to properly save size for and report more then 2Gb sized segment
of shared memory.

This makes it possible to use > 2 Gb shared memory segments on 64bit
architectures. Please note the new BUGS section in shmctl(2) and
UPDATING note for limitations of this temporal solution.

Reviewed by:	csjp
Tested by:	Nikolay Dzham <i levsha org ua>
MFC after:	2 weeks
2009-03-02 18:53:30 +00:00
David Schultz
601b205e47 Rewrite asprintf() as a wrapper around vasprintf(), thus reducing the
number of functions that have an incestuous relationship with the
arcane innards of stdio.
2009-03-02 04:11:42 +00:00
David Schultz
88f919d683 The argument corresponding to %zn is supposed to be an ssize_t *, not
a size_t *, although the distinction is moot in practice.
2009-03-02 04:07:58 +00:00
David Schultz
9e462ed058 Use C99-style initializers. No functional change.
Reviewed by:	md5(1)
2009-03-01 19:25:40 +00:00
Xin LI
a8da143ab8 Add a missing .El. 2009-03-01 05:47:14 +00:00
Xin LI
00d949789a "-isoC-99" should be spelled without 'c'. 2009-03-01 05:44:28 +00:00
Ed Schouten
6cf4a02c5e Add missing POSIX 1003.1-2008 open(2) flag; O_TTY_INIT.
On FreeBSD, this is the default behaviour. According to the spec, we may
give this flag a value of zero, but I'd rather not do this. If we define
it to a non-zero value, we can always change default behaviour without
changing the ABI. This is very unlikely to happen, though.
2009-02-28 10:10:30 +00:00
David Schultz
353ce11c8b Replace a dozen lines of code with a call to strnlen() / wcsnlen(). 2009-02-28 06:06:57 +00:00
David Schultz
9c5cb6d8ae Add restrict qualifiers.
I missed this file in my previous commit.
2009-02-28 06:05:37 +00:00
David Schultz
69099ba2ec - Add getdelim(), getline(), stpncpy(), strnlen(), wcsnlen(),
wcscasecmp(), and wcsncasecmp().
- Make some previously non-standard extensions visible
  if POSIX_VISIBLE >= 200809.
- Use restrict qualifiers in stpcpy().
- Declare off_t and size_t in stdio.h.
- Bump __FreeBSD_version in case the new symbols (particularly
  getline()) cause issues with ports.

Reviewed by:	standards@
2009-02-28 06:00:58 +00:00
David Schultz
e00a6d21eb Add restrict qualifiers to the parameters to strlcpy() and strlcat().
The annotation mainly just serves as a hint that they're not intended
for use with overlapping strings.
2009-02-28 05:15:02 +00:00
David Schultz
0881683b36 Make sure %zd treats negative arguments properly on 32-bit platforms.
Fix harmless but related bugs in %_$zd and %_$tu.

PR:		131880
MFC after:	1 week
2009-02-28 04:58:18 +00:00
Warner Losh
21fc9f2bcc These warnings are only relevant on NetBSD it seems. They don't seem
to be relevant to FreeBSD at all.
2009-02-19 19:53:58 +00:00
Warner Losh
51cbd5d9d7 These symbols don't belong here. Remove them. Since mips hasn't had
a release, I think there's no impact here...

Reviewed by:	cognet@
2009-02-19 18:03:41 +00:00
Ed Schouten
a73306e14e Properly invalidate highest pts number when calling setttyent().
When calling setttyent() after calling endttyent(), pts_valid will never
be set to 1, because the readdir()-loop will likely never vind a pts
that has a higher number than before.

Simplify the code by removing pts_valid. We'll just set maxpts to -1
when we don't have a valid count yet.
2009-02-12 19:32:52 +00:00
Ed Schouten
046f351281 Make ttyslot(3) work with pts(4) devices.
It seems ttyslot() calls rindex(), to strip the device name to the last
slash, but this is obviously invalid. /dev/pts/0 should be stripped
until pts/0. Because /etc/ttys only supports TTY names in /dev/, just
strip this piece of the pathname.
2009-02-12 19:00:13 +00:00
Ed Schouten
26d4f5e969 Add two new routines: fdevname() and fdevname_r().
A more elegant way of obtaining a name of a character device by its file
descriptor on FreeBSD, is to use the FIODGNAME ioctl. Because a valid
file descriptor implies a file descriptor is visible in /dev, it will
always resolve a valid device name.

I'm adding a more friendly wrapper for this ioctl, called fdevname(). It
is a lot easier to use than devname() and also has better error
handling. When a device name cannot be resolved, it will just return
NULL instead of a generated device name that makes no sense.

Discussed with:	kib
2009-02-11 20:24:59 +00:00
Hajimu UMEMOTO
aba831de03 Shutup warning for DNAME RR.
PR:		bin/127591
Submitted by:	"Eugene M. Kim" <20080111.freebsd.org__at__ab.ote.we.lv>
MFC after:	1 week
2009-02-08 16:58:05 +00:00
Giorgos Keramidas
0bc4c01d56 Fix language on atol(3) manpage. Add a COMPATIBILITY section
stating that in FreeBSD the atol() and atoll() functions affect
errno in the same way as strtol() and stroll().

PR:		docs/126487
Submitted by:	edwin
Reviewed by:	trhodes, gabor
MFC after:	1 week
2009-02-08 08:26:58 +00:00
Warner Losh
0ff7d9b4e9 Make sure the comparison is done with an unsigned char. 2009-02-07 19:34:44 +00:00
Jamie Gritton
b89e82dd87 Standardize the various prison_foo_ip[46] functions and prison_if to
return zero on success and an error code otherwise.  The possible errors
are EADDRNOTAVAIL if an address being checked for doesn't match the
prison, and EAFNOSUPPORT if the prison doesn't have any addresses in
that address family.  For most callers of these functions, use the
returned error code instead of e.g. a hard-coded EADDRNOTAVAIL or
EINVAL.

Always include a jailed() check in these functions, where a non-jailed
cred always returns success (and makes no changes).  Remove the explicit
jailed() checks that preceded many of the function calls.

Approved by:	bz (mentor)
2009-02-05 14:06:09 +00:00
Warner Losh
ea58272861 Fix the functions to match prototypes. The K&R definitions differ
from the ANSI-C prototype due to the 'int promotion' rule.
2009-02-03 20:25:36 +00:00
Daniel Gerzo
bd604b4b06 - ANSIfy function definitions
- use nul when we are looking for a terminating character where appropriate

Approved by:	imp
2009-02-03 17:58:20 +00:00
Roman Divacky
b1e58dd43e Provide a type for the argument.
Approved by:	kib (mentor)
2009-02-02 21:51:52 +00:00
Gabor Kovesdan
aa1c2a80b4 - Remove superfluous comment
PR:             docs/129400
Submitted by:   Gavin Atkinson <gavin@freebsd.org>
2009-01-30 15:28:35 +00:00
Tom Rhodes
48a01c432b Update the description of KERN_PROC.
PR:		100242
Reviewed by:	jhb
2009-01-28 15:21:38 +00:00
Tom Rhodes
f53807d218 Better wording for clearing EOF indicator.
Submitted by:	keramida and jhb
2009-01-28 14:38:41 +00:00
Tom Rhodes
f3f496333d Remove another comment about clearing EOF indicator.
Noticed by:	bde
2009-01-28 11:25:22 +00:00
David Schultz
aa83f5fff9 Update the manpage to reflect r145172. 2009-01-28 04:37:27 +00:00
Tom Rhodes
d568fa54db Remove comment about clearerr() being the only method of clearing
the EOF indicator, fseek() may also be used for this.

Bump document date.

PR:		76333
Submitted by:	Yoshihiko Sarumaru <mistral@imasy.or.jp>
2009-01-28 01:11:20 +00:00
Xin LI
481101b823 - Fix grammar. [1]
- Use the correct term 'long mode'. [2]
 - style(9) for return value. [3]

Submitted by:	Ben Kaduk <minimarmot gmail com> [1],
		obrien [2], scf [3]
2009-01-26 07:31:28 +00:00
Xin LI
4c6a60218c Rewrite of MI strlen(3) in a way that can better utilize modern hardware by
reducing branches and doing word-sized operation.

The idea is taken from J.T. Conklin's x86_64 optimized version of strlen(3)
for NetBSD, and reimplemented in C by me.

Discussed on:	-arch@
2009-01-25 23:08:47 +00:00
David Schultz
21ca178ece Add support for multibyte thousands_sep encodings, e.g., U+066C.
The integer thousands' separator code is rewritten in order to
avoid having to preallocate a buffer for the largest possible
digit string with the most possible instances of the longest
possible multibyte thousands' separator. The new version inserts
thousands' separators for integers using the same code as floating point.
2009-01-22 08:14:28 +00:00
David Schultz
f8f571931d - Add support for multibyte decimal_point encodings, e.g., U+066B.
A forthcoming gdtoa import is needed to make this fully work.
- Improve the way "nan(...)" is parsed.
2009-01-19 06:19:51 +00:00
David Schultz
5004a238c3 Add support for multibyte decimal_point encodings, e.g., U+066B. 2009-01-19 06:19:38 +00:00
David Schultz
a1805f7bb9 When f[w]printf() is called on an unbuffered file like stdout, it
sets up a fake buffered FILE and then effectively calls itself
recursively. Unfortunately, gcc doesn't know how to do tail call
elimination in this case, and actually makes things worse by
inlining __sbprintf(). This means that f[w]printf() to stderr was
allocating about 5k of stack on 64-bit platforms, much of which was
never used.

I've reorganized things to eliminate the waste. In addition to saving
some stack space, this improves performance in my tests by anywhere
from 5% to 17% (depending on the test) when -fstack-protector is
enabled. I found no statistically significant performance difference
when stack protection is turned off. (The tests redirected stderr to
/dev/null.)
2009-01-17 18:57:12 +00:00
David Schultz
6ec3512368 Simplify printf's inlined output buffering routines. On amd64, this
reduces the code size by about 10% and improves performance slightly.
2009-01-17 05:38:14 +00:00
Roman Divacky
f400c2b850 Change dstp to be const and remove bogus cast.
Submitted by:	christoph.mallon at gmx.de
Approved by:	kib (mentor)
2009-01-15 20:45:59 +00:00
Roman Divacky
f27b1c064c Introduce a local variable and use it instead of passed in parameter
to get rid of restrict qualifier discarding. This lets libc compile
cleanly in gnu99 mode.

Suggested by:	kib, christoph.mallon at gmx.de
Approved by:	kib (mentor)
2009-01-15 18:53:52 +00:00
David Schultz
0a4926406a Reduce code duplication by moving functions that are identical in both
vfprintf.c and vfwprintf.c (except for char/wchar_t differences) to a
common header file.
2009-01-15 04:49:43 +00:00
David Schultz
814d1bc906 Convert the insidious macros that handle printf()'s buffering into
slightly less evil inline functions, and move the buffering state into
a struct. This will make it possible for helper routines to produce
output for printf() directly, making it possible to untangle the code
somewhat.

In wprintf(), use the same buffering mechanism to reduce diffs to
printf(). This has the side-effect of causing wprintf() to catch write
errors that it previously ignored.
2009-01-15 04:29:02 +00:00
Konstantin Belousov
64d83d29b9 Document that ffsll(3) and flsll(3) functions first appeared in
FreeBSD 7.1

Submitted by:	Jan Henrik Sylvester <me janh de>
MFC after:	3 days
2009-01-13 13:19:42 +00:00
Daniel Gerzo
a28d1439d8 - add missing include
- fix struct memeber's name [1]

PR:		docs/130413 [1]
Submitted by:	Thomas Mueller <tmueller@sysgo.com> [1]
MFC after:	3 days
2009-01-12 13:12:02 +00:00
Xin LI
46714885b3 o Language improvements from OpenBSD;
o Use an ISC-style license as did by the author.

Obtained from:	OpenBSD
2009-01-12 06:10:48 +00:00
Xin LI
ba840c782f o ANSIfy.
o Use ISC style copyright as did by the author.

Obtained from:	OpenBSD
2009-01-12 06:09:34 +00:00
Ruslan Ermilov
efad698c19 Sort MLINKS. 2009-01-09 16:24:10 +00:00
David Schultz
0cab1fd236 Set the error indicator on an attempt to write to a read-only stream.
PR:		127335
MFC after:	2 weeks
2009-01-08 06:38:06 +00:00
Bjoern A. Zeeb
73de1e8395 Document the special loopback address behaviour of jails.
PR:		kern/103464
Submitted by:	brueffer (correct markup)
Reviewed by:	brueffer
MFC after:	2 weeks
2009-01-06 18:10:17 +00:00
Daniel Gerzo
19cc5aa64b - forgot to bump a date 2009-01-06 13:10:15 +00:00
Daniel Gerzo
7cfc1e329f catch up wtih r175955 by ume:
- the support of AI_ALL and AI_V4MAPPED has been completely removed.
2009-01-06 13:05:58 +00:00
Tom Rhodes
f3cac808e9 Note that the protocol argument can be set to 0.
PR:		127890
Reviewed by:	rwatson
2009-01-05 12:18:46 +00:00
Tom Rhodes
eaca7c7bc4 Document that kldunloadf can return EINVAL.
PR:		125639
2008-12-25 09:15:31 +00:00
Marcel Moolenaar
74aed9855d Add support for the FPA floating-point format on ARM. The
FPA floating-point format is identical to the VFP format,
but is always stored in big-endian.
Introduce _IEEE_WORD_ORDER to describe the byte-order of
the FP representation.

Obtained from:	Juniper Networks, Inc
2008-12-23 22:20:59 +00:00
Murray Stokely
4e543e5c37 Add an ENVIRONMENT section to note that the RSH variable can be set to
override the use of the rsh(1) program in rcmd(3).

PR:		docs/51133
Obtained from:	NetBSD, partially
MFC after:	3 weeks
2008-12-14 22:48:48 +00:00
Hajimu UMEMOTO
54ebdd631d Merge the resolver part of BIND 9.4.3 into HEAD.
It includes the following fix:

  2426.   [bug]           libbind: inet_net_pton() can sometimes return the
                          wrong value if excessively large netmasks are
                          supplied. [RT #18512]

Reported by:	Maksymilian Arciemowicz <cxib__at__securityreason.com>
2008-12-14 19:39:53 +00:00
David Schultz
e18701f4ac Consolidate some variable initializations. No substantive change. 2008-12-11 02:39:27 +00:00
David Schultz
33bff5d3e4 Move the xprintf hook to where it belongs; it shouldn't be in the
middle of vfprintf's variable declarations.
2008-12-10 02:32:06 +00:00
Maxim Konovalov
9435575dbe o Use full month name in .Dd macro. 2008-12-09 09:24:25 +00:00
Konstantin Belousov
f0eca40a14 Import the strndup(3) function.
Copyright attribution is kept the same as in original NetBSD source.

Submitted by:	Florian Smeets <flo kasimir com>
Obtained from:	NetBSD
MFC after:	2 weeks
2008-12-06 09:37:54 +00:00
Konstantin Belousov
6197062881 Order the str*.c files mostly alphabetical.
Submitted by:	Florian Smeets <flo kasimir com>
MFC after:	2 weeks
2008-12-06 09:28:46 +00:00
Pawel Jakub Dawidek
3027fbe00b Add an easier example.
Reviewed by:	trasz
2008-12-05 15:50:59 +00:00
Giorgos Keramidas
a294460257 The times(3) function returns the number of CLK_TCKs since the
startup time of FreeBSD, not since the UNIX Epoch.

PR:		docs/122359
Submitted by:	Viktor &#352;tujber
MFC after:	1 week
2008-12-01 15:27:00 +00:00
Ruslan Ermilov
e95f37bb69 Fix fread() to return a correct value on platforms where sizeof(int) !=
sizeof(size_t), i.e. on all 64-bit platforms.

Reported by:	Andrey V. Elsukov
MFC after:	3 days
2008-12-01 14:33:34 +00:00
Jason Evans
d7ba3e423a Fix a lock order reversal bug that could cause deadlock during fork(2).
Reported by:	kib
2008-12-01 10:20:59 +00:00
Ivan Voras
1a2bea865b It's silly to claim recv(2) is to be removed in favour of recvfrom(2)
(at least at this time :) ).

Approved by:	gnn (mentor)
2008-11-30 21:40:01 +00:00
Jason Evans
17daa728ae Adjust an assertion to handle the case where a lock is contested, but
spinning is avoided due to running on a single-CPU system.

Reported by:	stefanf
2008-11-30 19:30:31 +00:00
Jason Evans
93e34865fa Do not spin when trying to lock on a single-CPU system.
Reported by:	davidxu
2008-11-30 05:55:24 +00:00
Bjoern A. Zeeb
413628a7e3 MFp4:
Bring in updated jail support from bz_jail branch.

This enhances the current jail implementation to permit multiple
addresses per jail. In addtion to IPv4, IPv6 is supported as well.
Due to updated checks it is even possible to have jails without
an IP address at all, which basically gives one a chroot with
restricted process view, no networking,..

SCTP support was updated and supports IPv6 in jails as well.

Cpuset support permits jails to be bound to specific processor
sets after creation.

Jails can have an unrestricted (no duplicate protection, etc.) name
in addition to the hostname. The jail name cannot be changed from
within a jail and is considered to be used for management purposes
or as audit-token in the future.

DDB 'show jails' command was added to aid debugging.

Proper compat support permits 32bit jail binaries to be used on 64bit
systems to manage jails. Also backward compatibility was preserved where
possible: for jail v1 syscalls, as well as with user space management
utilities.

Both jail as well as prison version were updated for the new features.
A gap was intentionally left as the intermediate versions had been
used by various patches floating around the last years.

Bump __FreeBSD_version for the afore mentioned and in kernel changes.

Special thanks to:
- Pawel Jakub Dawidek (pjd) for his multi-IPv4 patches
  and Olivier Houchard (cognet) for initial single-IPv6 patches.
- Jeff Roberson (jeff) and Randall Stewart (rrs) for their
  help, ideas and review on cpuset and SCTP support.
- Robert Watson (rwatson) for lots and lots of help, discussions,
  suggestions and review of most of the patch at various stages.
- John Baldwin (jhb) for his help.
- Simon L. Nielsen (simon) as early adopter testing changes
  on cluster machines as well as all the testers and people
  who provided feedback the last months on freebsd-jail and
  other channels.
- My employer, CK Software GmbH, for the support so I could work on this.

Reviewed by:	(see above)
MFC after:	3 months (this is just so that I get the mail)
X-MFC Before:   7.2-RELEASE if possible
2008-11-29 14:32:14 +00:00
Konstantin Belousov
cb5c4b10ba Add two rtld exported symbols, _rtld_atfork_pre and _rtld_atfork_post.
Threading library calls _pre before the fork, allowing the rtld to
lock itself to ensure that other threads of the process are out of
dynamic linker. _post releases the locks.

This allows the rtld to have consistent state in the child. Although
child may legitimately call only async-safe functions, the call may
need plt relocation resolution, and this requires working rtld.

Reported and debugging help by:	rink
Reviewed by:	kan, davidxu
MFC after:	1 month (anyway, not before 7.1 is out)
2008-11-27 11:27:59 +00:00
Pawel Jakub Dawidek
1ba4a712dd Update ZFS from version 6 to 13 and bring some FreeBSD-specific changes.
This bring huge amount of changes, I'll enumerate only user-visible changes:

- Delegated Administration

	Allows regular users to perform ZFS operations, like file system
	creation, snapshot creation, etc.

- L2ARC

	Level 2 cache for ZFS - allows to use additional disks for cache.
	Huge performance improvements mostly for random read of mostly
	static content.

- slog

	Allow to use additional disks for ZFS Intent Log to speed up
	operations like fsync(2).

- vfs.zfs.super_owner

	Allows regular users to perform privileged operations on files stored
	on ZFS file systems owned by him. Very careful with this one.

- chflags(2)

	Not all the flags are supported. This still needs work.

- ZFSBoot

	Support to boot off of ZFS pool. Not finished, AFAIK.

	Submitted by:	dfr

- Snapshot properties

- New failure modes

	Before if write requested failed, system paniced. Now one
	can select from one of three failure modes:
	- panic - panic on write error
	- wait - wait for disk to reappear
	- continue - serve read requests if possible, block write requests

- Refquota, refreservation properties

	Just quota and reservation properties, but don't count space consumed
	by children file systems, clones and snapshots.

- Sparse volumes

	ZVOLs that don't reserve space in the pool.

- External attributes

	Compatible with extattr(2).

- NFSv4-ACLs

	Not sure about the status, might not be complete yet.

	Submitted by:	trasz

- Creation-time properties

- Regression tests for zpool(8) command.

Obtained from:	OpenSolaris
2008-11-17 20:49:29 +00:00
Peter Wemm
9b16c7add1 On i386, the primary function that SYSCALL() generates is with the
__sys_ prefix.  Make END() match.  This didn't cause a compile error, but
the function size is attached to the .weak symbol, not the real one.
2008-11-15 22:23:07 +00:00
Ed Schouten
ab0d10f68e Several cleanups related to pipe(2).
- Use `fildes[2]' instead of `*fildes' to make more clear that pipe(2)
  fills an array with two descriptors.

- Remove EFAULT from the manual page. Because of the current calling
  convention, pipe(2) raises a segmentation fault when an invalid
  address is passed.

- Introduce kern_pipe() to make it easier for binary emulations to
  implement pipe(2).

- Make Linux binary emulation use kern_pipe(), which means we don't have
  to recover td_retval after calling the FreeBSD system call.

Approved by:	rdivacky
Discussed on:	arch
2008-11-11 14:55:59 +00:00
Ed Schouten
a1b5a8955e Mark uname(), getdomainname() and setdomainname() with COMPAT_FREEBSD4.
Looking at our source code history, it seems the uname(),
getdomainname() and setdomainname() system calls got deprecated
somewhere after FreeBSD 1.1, but they have never been phased out
properly. Because we don't have a COMPAT_FREEBSD1, just use
COMPAT_FREEBSD4.

Also fix the Linuxolator to build without the setdomainname() routine by
just making it call userland_sysctl on kern.domainname. Also replace the
setdomainname()'s implementation to use this approach, because we're
duplicating code with sysctl_domainname().

I wasn't able to keep these three routines working in our
COMPAT_FREEBSD32, because that would require yet another keyword for
syscalls.master (COMPAT4+NOPROTO). Because this routine is probably
unused already, this won't be a problem in practice. If it turns out to
be a problem, we'll just restore this functionality.

Reviewed by:	rdivacky, kib
2008-11-09 10:45:13 +00:00
Edward Tomasz Napierala
7968104d73 Add one more EACCES clause to rename.2.
Approved by:	rwatson (mentor)
2008-11-07 15:01:40 +00:00
Warner Losh
68b2399298 Replace the non-standard disclaimer with the standard one from /COPYRIGHT
Approved by:	jedgar@
2008-11-04 00:20:43 +00:00
Jason Evans
b74d3e0c37 Revert to preferring mmap(2) over sbrk(2) when mapping memory, due to
potential extreme contention in the kernel for multi-threaded applications
on SMP systems.

Reported by:	kris
2008-11-03 21:17:18 +00:00
Doug Rabson
a9148abd9d Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager.  I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.

The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.

To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.

As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.

Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.

The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.

Sponsored by:	Isilon Systems
MFC after:	1 month
2008-11-03 10:38:00 +00:00
Konstantin Belousov
4a723bd20c Add the ffsll and flsll functions. These are ffs and fls operating
on long long arguments.

Reviewed by:	bde (previous version, that included asm implementation
	for all ffs and fls functions on i386 and amd64)
MFC after:	2 weeks
2008-11-03 10:22:19 +00:00