Commit Graph

1496 Commits

Author SHA1 Message Date
Xin LI
64c12e81e2 Add prototype for libc internal interfaces. 2010-03-31 18:37:00 +00:00
Xin LI
9fd9d097aa Add prototypes for libc private interfaces.
While I'm there, apply __unused whenever appropriate.

Reviewed by:	md5(1)
2010-03-31 18:36:04 +00:00
Pietro Cerutti
071ab531db - Remove const'ness from dlerror(3) prototype, for consistency with POSIX.
Approved by:	cognet
MFC after:	1 week
2010-03-24 15:59:51 +00:00
Ed Schouten
070f2a9831 Let opendir() use O_DIRECTORY.
I am not removing the fstat() calls here, since we cannot yet assume
people will always run kernels that respect O_DIRECTORY.
2010-03-21 20:45:06 +00:00
Poul-Henning Kamp
156a1661a6 Comment a fine point, so it does not get lost when people borrow code
from FreeBSD for other purposes.
2010-03-15 08:58:35 +00:00
Joel Dahl
e1c6ef6aa4 The NetBSD Foundation has granted permission to remove clause 3 and 4 from
their software.

Obtained from:	NetBSD
2010-03-02 17:20:04 +00:00
Edwin Groothuis
dcfeda6122 Split the contributed code from libc/stdtime from lib/libc/stdtime
to contrib/tzcode/stdtime.
2010-02-26 06:44:00 +00:00
Konstantin Belousov
4d44fc9c59 Make pause(3) implementation not depended on the legacy sigcompat.c
interfaces. Do not block rt signals during and after pause(3) calls.
Use private libc namespace to call proper methods.

MFC after:	1 week
2010-02-25 13:51:11 +00:00
Ed Schouten
3878829eeb While there, trim some trailing whitespace. 2010-02-21 14:58:01 +00:00
Ed Schouten
62399df2c9 Add proper const keywords to sysctl(3) parameters.
The `name' and `newp' arguments can be marked const, because the buffers
they refer to are never changed. While there, perform some other
cleanups:

- Remove K&R from sysctl.c.
- Implement sysctlbyname() using sysctlnametomib() to prevent
  duplication of an undocumented kernel interface.
- Fix some whitespace nits.

It seems the prototypes are now in sync with NetBSD as well.
2010-02-21 13:57:02 +00:00
Marcel Moolenaar
9436852167 The static TLS size as given by tls_static_space includes TLS_TCB_SIZE
bytes of TCB in variant I.
2010-02-16 02:22:59 +00:00
Ed Schouten
1e7a08440a Also add a cross-reference to NetBSD updlastlogx(). 2010-02-03 19:31:02 +00:00
Gavin Atkinson
9ba42503a5 Bump .Dd, forgotten in r203393
Approved by:	ed (mentor, implicit)
MFC after:	1 week
2010-02-02 19:44:51 +00:00
Gavin Atkinson
028a9a13eb The multiplicand a = 0x5deece66d = 25214903917, not 0xfdeece66d.
This bug in the man page has gone unnoticed for over 15 years!

PR:		docs/143461
Submitted by:	Jeremy Huddleston  jeremyhu apple.com
Approved by:	ed (mentor, implicit)
MFC after:	1 week
2010-02-02 19:28:01 +00:00
Ed Schouten
49e5c8f314 Perform some cleanups to devname(3).
- Make sure the mode argument is either a character or a block device.
- Use S_IS*() instead of checking S_IF*-flags by hand.
- Don't use kern.devname when the argument is already NODEV.
- Always call snprintf with the proper amount of arguments corresponding
  with the format.
- Perform some whitespace fixes. Tabs instead of 4 spaces, missing space
  for return statement.
- Remove unneeded includes.
2010-01-31 14:51:04 +00:00
Ed Schouten
bcc7f0f408 Remove pseudo-terminals from ttys(5).
When we had utmp(5), we had to list all the psuedo-terminals in ttys(5)
to make ttyslot(3) function properly. Now that pututxline(3) deals with
slot allocation internally (not based on TTY names), we don't need to
list all the TTYs on the system in ttys(5) to make user accounting work
properly.

This patch removes all the entries from the /etc/ttys files, but also
the pts(4) entries that were appended implicitly, which was added in
r154838.
2010-01-27 11:54:42 +00:00
Ed Schouten
89c3567d32 Improve the ttyname(3) manual page.
- Remove unrelated references to tty(5).
- Remove unneeded relation with FILE *.
- Add better cross references.
2010-01-24 14:44:05 +00:00
Ed Schouten
9d98195dc3 EMPTY records don't have a timestamp. 2010-01-23 17:58:40 +00:00
Antoine Brodin
dd554467bb Reapply r201145 to lib/libc/gen/sem.c 2010-01-23 12:48:46 +00:00
Ed Schouten
a7607816bf Just ignore the timestamps given to pututxline().
I've noticed many applications do a bad job at timekeeping, for several
reasons:

- Applications like screen(1) don't update time records when restoring
  the old user login record.
- Many applications only set ut_tv.tv_sec, not ut_tv.tv_usec.

This causes many problems for tools such as ac(8), which require the
timestamps to be properly ordered. This is why I've decided to let the
utmpx code obtain valid timestamps itself.
2010-01-23 08:43:21 +00:00
Ed Schouten
f5ec5ddec2 English nitpicking.
Submitted by:	jmallett
2010-01-22 05:19:51 +00:00
Ed Schouten
5b2e6b2a90 Describe why pututxline() doesn't entirely conform to standards. 2010-01-22 05:09:10 +00:00
Ed Schouten
d17ad825d6 Remove comments about breaking the specification.
I've discussed this issue with the Austin Group and it will be fixed in
future revisions of the specification. The issue was that ut_line fields
weren't supposed to be valid for LOGIN_PROCESS entries, while
getutxline() would try to match these records anyway.

They also agreed on our way of implementing pututxline() without
getutxid() (which other operating systems also do), but unfortunately
they disagreed with our way of replacing DEAD_PROCESS entries, which is
a pity. The current specification allows the utmpx database to become
infinitely big over time.

See also:	http://austingroupbugs.net/view.php?id=213#c378
2010-01-22 04:53:08 +00:00
Andrey A. Chernov
5fc5e42a2e Style: reword comment.
Submitted by:   bde
2010-01-20 11:59:46 +00:00
Andrey A. Chernov
e5732e1803 For alphasort() add reference to strcoll(3) 2010-01-20 11:55:14 +00:00
Andrey A. Chernov
e5c9c8533d Style: rename internal function to opendir_compar()
Pointed by:     bde
2010-01-20 07:36:29 +00:00
Andrey A. Chernov
888ee87295 Style: remove extra empty line in the comment.
Pointed by:     bde
2010-01-20 07:27:56 +00:00
Ed Schouten
26f87cc6ff Revert r202447 by re-exposing the old uname(3) function.
It makes hardly any sense to expose a symbol which should only be
provided for binary compatibility, but it seems we don't have a lot of
choice here. There are many autoconf scripts out there that try to
create a binary that links against the old symbol to see whether
uname(3) is present. These scripts fail to detect uname(3) now.

It should be noted that the behaviour we implement is not against the
standards:

| The following shall be declared as a function and may also be defined
| as a macro:
|
| int uname(struct utsname *);
2010-01-19 23:07:12 +00:00
Andrey A. Chernov
b9a74f2ad5 Double checking my commit I found that comment saying that
POSIX 2008 and XSI 7require strcoll() for opendir() is not true.
I can't find such requirement in POSIX 2008 and XSI 7.

So, back out that part of my commit, returning old strcmp(), and remove
this misleading comment.
2010-01-18 13:44:44 +00:00
David Xu
4c1c132bf4 preserve errno when processing error cases. 2010-01-18 10:29:04 +00:00
Andrey A. Chernov
dcdafd0e92 a) Use strcoll() in opendir() and alphasort() as POSIX 2008 requires.
It also matches now how our 'ls' works for years.

b) Remove comment expressed 2 fears:
 1) One just simple describe how strcoll() works in _any_ context,
 not for directories only. Are we plan to remove strcoll() from everything
 just because it is little more complex than strcmp()? I doubt, and
 directories give nothing different here. Moreover, strcoll() used
 in 'ls' for years and nobody complaints yet.

 2) Plain wrong statement about undefined strcoll() behaviour. strcoll()
 always gives predictable results, falling back to strcmp() on any
 trouble, see strcoll(3).

No objections from -current list discussion.
2010-01-18 10:17:51 +00:00
Ed Schouten
98c63a48e9 Perform several small cleanups to the utmpx code.
- Massively reduce BSS usage. Let futx_to_utx() dynamically allocate the
  structure. There is only a very small amount of applications out there
  that needs to use the utmpx database. Wasting 1 KB on unused
  structures makes little sense.

- Just let getutxid() search for matching ut_id's for any *PROCESS-type.
  This makes the code a bit more future-proof.

- Fix a POSIX-mistake: when reading POSIX and the OpenSolaris
  implementation, getutxline() must return USER_PROCESS and
  LOGIN_PROCESS records whose ut_lines match. When reading POSIX, it
  seems LOGIN_PROCESS should not use ut_line at the first place. I have
  reported this issue.
2010-01-17 21:40:05 +00:00
Ed Schouten
e35a88d3a6 Add forgotten break; keyword to getutxid().
We should not fall through to the ut_id comparison. Only ut_type should
be compared when using OLD_TIME, NEW_TIME, BOOT_TIME or SHUTDOWN_TIME.
2010-01-17 21:00:29 +00:00
Ed Schouten
79a7dbf111 Simplify ttyslot(3).
After comparing how other systems deal with utmp/utmpx, I noticed many
systems don't even care about ttyslot(3) anymore, since utmpx doesn't
use TTY slots anyway. We don't provide any tools to access old utmp
files anymore, so there is no use in letting applications write to a
proper offset within the utmp file.

Just let ttyslot(3) always return 0, which seems to be the default
behaviour on operating systems like Linux as well.
2010-01-17 15:43:14 +00:00
Ed Schouten
023b02dea7 Unexpose the old uname(3) function.
Nowadays uname(3) is an inline function around __xuname(3). Prevent
linkage of new binaries against this compatibility function, similar to
what I did with ttyslot(3).
2010-01-16 17:05:27 +00:00
David Xu
764ce7ce7d Also call sem_module_init in sem_close to initialize mutex
with some attributes.
2010-01-15 01:19:58 +00:00
Ed Schouten
5ab7f1fc40 Add wtmpcvt(1).
This utility allows users to convert their wtmp databases to the new
format. It makes no sense for users to keep their wtmp log files if they
are unable to view them.

It basically copies ut_line into ut_id as well. This makes it possible
for last(1) and ac(8) to match login records with their corresponding
logout record.
2010-01-14 20:58:45 +00:00
Ed Schouten
c068466245 Remove ttyslot from Symbol.map anyway.
Requested by:	kan
2010-01-14 15:20:46 +00:00
Ed Schouten
6386f4da2a Unbreak pututxline() on 32-bit architectures.
I forgot to cast the size_t's back to off_t before negating them,
causing all sorts of artifacts where the log files would grow to 2^32 -
197 bytes.

Reported by:	ume
2010-01-14 15:20:09 +00:00
Ed Schouten
d496b9d0d4 Revert the change to Symbol.map, made in r202274.
Even though we use __sym_compat(), we should list the symbol in
Symbol.map.

ttyslot() is now listed as follows, which seems to do the right thing:

| Symbol table '.dynsym' contains 2755 entries:
|    Num:    Value          Size Type    Bind   Vis      Ndx Name
|    613: 00000000000477b0   121 FUNC    GLOBAL DEFAULT   10 ttyslot@FBSD_1.0

Reported by:	kib
2010-01-14 10:00:01 +00:00
Ed Schouten
7bc9f25fd0 Don't use fseeko() to obtain the file offset.
I was a bit confused with lseek(), which returns the new offset. We
should ftello() to obtain it using stdio.
2010-01-14 08:08:55 +00:00
Ed Schouten
9457bcdc60 Add two changes that should have gone into commit r202274.
Phase out ttyslot(3).

  The ttyslot() function was originally part for SUSv1, marked LEGACY in
  SUSv2 and removed later on. This function only makes sense when using
  utmp(5), because it was used to determine the offset of the record for
  the controlling TTY. It makes little sense to keep it here, because the
  new utmpx file format doesn't index based on TTY slots.
2010-01-14 05:37:43 +00:00
Ed Schouten
88b69f52ee Phase out ttyslot(3).
The ttyslot() function was originally part for SUSv1, marked LEGACY in
SUSv2 and removed later on. This function only makes sense when using
utmp(5), because it was used to determine the offset of the record for
the controlling TTY. It makes little sense to keep it here, because the
new utmpx file format doesn't index based on TTY slots.
2010-01-14 05:35:32 +00:00
Ed Schouten
a627ac61ab Implement <utmpx.h>.
The utmpx interface is the standardized interface of the user accounting
database. The standard only defines a subset of the functions that were
present in System V-like systems.

I'd like to highlight some of the traits my implementation has:

- The standard allows the on-disk format to be different than the
  in-memory representation (struct utmpx). Most operating systems don't
  do this, but we do. This allows us to keep our ABI more stable, while
  giving us the opportunity to modify the on-disk format. It also allows
  us to use a common file format across different architectures (i.e.
  byte ordering).

- Our implementation of pututxline() also updates wtmp and lastlog (now
  called utx.log and utx.lastlogin). This means the databases are more
  likely to be in sync.

- Care must be taken that our implementation discard any fields that are
  not applicable. For example, our DEAD_PROCESS records do not hold a
  TTY name. Just a time stamp, a record identifier and a process
  identifier. It also guarantees that strings (ut_host, ut_line and
  ut_user) are null terminated. ut_id is obviously not null terminated,
  because it's not a string.

- The API and its behaviour should be conformant to POSIX, but there may
  be things that slightly deviate from the standard. This implementation
  uses separate file descriptors when writing to the log files. It also
  doesn't use getutxid() to search for a field to overwrite. It uses an
  allocation strategy similar to getutxid(), but prevents DEAD_PROCESS
  records from accumulating.

Make sure libulog doesn't overwrite the manpages shipped with our C
library. Also keep the symbol list in Symbol.map sorted.

I'll bump __FreeBSD_version later this evening. I first want to convert
everything to <utmpx.h> and get rid of <utmp.h>.
2010-01-13 17:29:55 +00:00
David Xu
41e160536a Return SEM_FAILED instead of NULL, though there are same, but the
SEM_FAILED is more suitable name.
In function, sem_close(), always set errno on error.
2010-01-13 08:53:23 +00:00
David Xu
7bf27b2dde Update manuals of sem_open and sem_init.
Submitted by:	ru
2010-01-12 01:30:05 +00:00
David Xu
a455039e3a Update manual for sem_init and sem_open, restrictions of shared semaphore
and 14 characters in name length no longer exist.

Reviewed by:	deischen@
2010-01-09 05:40:46 +00:00
Edward Tomasz Napierala
10302b1ade Remove BUGS section that no longer applies after recent changes to semaphore
code.

OK-ed by:	davidxu
2010-01-07 16:52:00 +00:00
David Xu
323d80a0a7 Don't forget to use fourth argument if O_CREAT is set in argument oflag.
The fourth specifies initial value for the semaphore.
2010-01-07 04:15:49 +00:00
Konstantin Belousov
f5636f881b Do not rely on behaviour undefined by ANSI C, use thunks to adapt
alphasort-like interface to the comparision function required by
qsort() and qsort_r().

For opendir() thunk and alphasort(), comment on why we deviated from
POSIX by using strcmp() instead of strcoll().

Requested and reviewed by:	bde
MFC after:	2 weeks
2010-01-05 20:20:31 +00:00