diff options
Diffstat (limited to 'lib/libc/gen')
| -rw-r--r-- | lib/libc/gen/fstab.c | 29 | ||||
| -rw-r--r-- | lib/libc/gen/getloadavg.3 | 1 | ||||
| -rw-r--r-- | lib/libc/gen/getobjformat.3 | 16 | ||||
| -rw-r--r-- | lib/libc/gen/getpwent.3 | 4 | ||||
| -rw-r--r-- | lib/libc/gen/getpwent.c | 4 | ||||
| -rw-r--r-- | lib/libc/gen/getvfsbyname.c | 4 | ||||
| -rw-r--r-- | lib/libc/gen/getvfsent.c | 11 | ||||
| -rw-r--r-- | lib/libc/gen/nlist.c | 136 | ||||
| -rw-r--r-- | lib/libc/gen/popen.3 | 9 | ||||
| -rw-r--r-- | lib/libc/gen/psignal.3 | 4 | ||||
| -rw-r--r-- | lib/libc/gen/psignal.c | 6 | ||||
| -rw-r--r-- | lib/libc/gen/setmode.3 | 11 | ||||
| -rw-r--r-- | lib/libc/gen/sysctl.3 | 5 | ||||
| -rw-r--r-- | lib/libc/gen/sysctl.c | 12 | ||||
| -rw-r--r-- | lib/libc/gen/tzset.3 | 4 |
15 files changed, 86 insertions, 170 deletions
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c index 65b02c1906658..a5260687149a3 100644 --- a/lib/libc/gen/fstab.c +++ b/lib/libc/gen/fstab.c @@ -35,13 +35,8 @@ static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/stat.h> - #include <errno.h> #include <fstab.h> -#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -52,30 +47,8 @@ static struct fstab _fs_fstab; static int LineNo = 0; static void error __P((int)); -static void fixfsfile __P((void)); static int fstabscan __P((void)); -static void -fixfsfile() -{ - static char buf[sizeof(_PATH_DEV) + MNAMELEN]; - struct stat sb; - struct statfs sf; - - if (strcmp(_fs_fstab.fs_file, "/") != 0) - return; - if (statfs("/", &sf) != 0) - return; - if (sf.f_mntfromname[0] == '/') - buf[0] = '\0'; - else - strcpy(buf, _PATH_DEV); - strcat(buf, sf.f_mntfromname); - if (stat(buf, &sb) != 0 || !S_ISBLK(sb.st_mode)) - return; - _fs_fstab.fs_spec = buf; -} - static int fstabscan() { @@ -96,7 +69,6 @@ fstabscan() if (!strpbrk(p, " \t")) { _fs_fstab.fs_spec = strsep(&p, ":\n"); _fs_fstab.fs_file = strsep(&p, ":\n"); - fixfsfile(); _fs_fstab.fs_type = strsep(&p, ":\n"); if (_fs_fstab.fs_type) { if (!strcmp(_fs_fstab.fs_type, FSTAB_XX)) @@ -124,7 +96,6 @@ fstabscan() while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; _fs_fstab.fs_file = cp; - fixfsfile(); while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0') ; _fs_fstab.fs_vfstype = cp; diff --git a/lib/libc/gen/getloadavg.3 b/lib/libc/gen/getloadavg.3 index 8d8facf4b8b4d..fa5b5715a5ff9 100644 --- a/lib/libc/gen/getloadavg.3 +++ b/lib/libc/gen/getloadavg.3 @@ -38,7 +38,6 @@ .Nm getloadavg .Nd get system load averages .Sh SYNOPSIS -.Fd #include <stdlib.h> .Ft int .Fn getloadavg "double loadavg[]" "int nelem" .Sh DESCRIPTION diff --git a/lib/libc/gen/getobjformat.3 b/lib/libc/gen/getobjformat.3 index ad7ff438b234d..228bb5f448834 100644 --- a/lib/libc/gen/getobjformat.3 +++ b/lib/libc/gen/getobjformat.3 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: getobjformat.3,v 1.1 1998/09/09 01:21:24 jdp Exp $ +.\" $Id$ .\" .Dd September 7, 1998 .Dt GETOBJFORMAT 3 @@ -103,22 +103,12 @@ and its null terminator, returns -1. In that case, the contents of the buffer and argument vector supplied by the caller are indeterminate. .Sh ENVIRONMENT -.Bl -tag -width OBJFORMAT -.It Ev OBJFORMAT -If the environment variable .Ev OBJFORMAT -is set, it overrides the default object file format. -.Ev OBJFORMAT takes precedence over -.Pa /etc/objformat . .Sh FILES -.Bl -tag -width /etc/objformat -compact -.It Pa /etc/objformat -If present, specifies the object file format to use. Syntax is -.Ql OBJFORMAT=xxx . +.Pa /etc/objformat .Sh SEE ALSO .Xr objformat 1 .Sh HISTORY The .Fn getobjformat -function first appeared in -.Fx 3.0 . +function first appeared in FreeBSD 3.0. diff --git a/lib/libc/gen/getpwent.3 b/lib/libc/gen/getpwent.3 index 94fc4063f30b4..8772a429e7e49 100644 --- a/lib/libc/gen/getpwent.3 +++ b/lib/libc/gen/getpwent.3 @@ -72,8 +72,8 @@ file struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* encrypted password */ - uid_t pw_uid; /* user uid */ - gid_t pw_gid; /* user gid */ + int pw_uid; /* user uid */ + int pw_gid; /* user gid */ time_t pw_change; /* password change time */ char *pw_class; /* user access class */ char *pw_gecos; /* Honeywell login info */ diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 2ee0e32aabc7b..02ec190519fed 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -154,9 +154,7 @@ getpwnam(name) bf[0] = _PW_KEYBYNAME; len = strlen(name); - if (len > UT_NAMESIZE) - return(NULL); - bcopy(name, bf + 1, len); + bcopy(name, bf + 1, MIN(len, UT_NAMESIZE)); key.data = (u_char *)bf; key.size = len + 1; rval = __hashpw(&key); diff --git a/lib/libc/gen/getvfsbyname.c b/lib/libc/gen/getvfsbyname.c index 7f8a9703710a1..57d1db4e7744c 100644 --- a/lib/libc/gen/getvfsbyname.c +++ b/lib/libc/gen/getvfsbyname.c @@ -36,13 +36,15 @@ static char sccsid[] = "@(#)kvm_getvfsbyname.c 8.1 (Berkeley) 4/3/95"; #endif static const char rcsid[] = - "$Id: getvfsbyname.c,v 1.3 1998/03/09 04:36:07 jb Exp $"; + "$Id: getvfsbyname.c,v 1.2 1997/03/03 13:08:33 bde Exp $"; #endif /* not lint */ +#define _NEW_VFSCONF #include <sys/param.h> #include <sys/mount.h> #include <sys/sysctl.h> #include <errno.h> +#include <kvm.h> /* * Given a filesystem name, determine if it is resident in the kernel, diff --git a/lib/libc/gen/getvfsent.c b/lib/libc/gen/getvfsent.c index 8aa147db76aba..469ef975c1e94 100644 --- a/lib/libc/gen/getvfsent.c +++ b/lib/libc/gen/getvfsent.c @@ -193,7 +193,6 @@ vfspath(const char *name) int vfsisloadable(const char *name) { -#if 0 int fd; fd = open("/dev/lkm", O_RDWR, 0); @@ -203,24 +202,16 @@ vfsisloadable(const char *name) close(fd); return !!vfspath(name); -#else - return 1; -#endif } int vfsload(const char *name) { - const char *path; + const char *path = vfspath(name); char name_mod[sizeof("_mod") + strlen(name)]; pid_t pid; int status; - status = kldload(name); - if (status != -1) - return 0; - - path = vfspath(name); if(!path) { errno = ENOENT; return -1; diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index 55f4f3978bb0f..ebd4234c9c2a6 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -29,8 +29,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #if defined(LIBC_SCCS) && !defined(lint) @@ -199,7 +197,18 @@ __aout_fdnlist(fd, list) #endif #ifdef _NLIST_DO_ELF -static void elf_sym_to_nlist __P((struct nlist *, Elf_Sym *, Elf_Shdr *, int)); + +#if ELF_TARG_CLASS == ELFCLASS32 + +#define Elf(x) Elf32_##x +#define ELF(x) ELF32_##x + +#else + +#define Elf(x) Elf64_##x +#define ELF(x) ELF64_##x + +#endif /* * __elf_is_okay__ - Determine if ehdr really @@ -210,13 +219,13 @@ static void elf_sym_to_nlist __P((struct nlist *, Elf_Sym *, Elf_Shdr *, int)); */ int __elf_is_okay__(ehdr) - register Elf_Ehdr *ehdr; + register Elf(Ehdr) *ehdr; { register int retval = 0; /* * We need to check magic, class size, endianess, * and version before we look at the rest of the - * Elf_Ehdr structure. These few elements are + * Elf(Ehdr) structure. These few elements are * represented in a machine independant fashion. */ if (IS_ELF(*ehdr) && @@ -238,19 +247,15 @@ __elf_fdnlist(fd, list) register struct nlist *list; { register struct nlist *p; + register caddr_t strtab; register Elf_Off symoff = 0, symstroff = 0; register Elf_Word symsize = 0, symstrsize = 0; - register Elf_Sword cc, i; - int nent = -1; - int errsave; + register Elf_Sword nent, cc, i; Elf_Sym sbuf[1024]; Elf_Sym *s; Elf_Ehdr ehdr; - char *strtab = NULL; Elf_Shdr *shdr = NULL; - Elf_Shdr *sh; Elf_Word shdr_size; - void *base; struct stat st; /* Make sure obj is OK */ @@ -270,11 +275,10 @@ __elf_fdnlist(fd, list) } /* mmap section header table */ - base = mmap(NULL, (size_t)shdr_size, PROT_READ, 0, fd, - (off_t)ehdr.e_shoff); - if (base == MAP_FAILED) + shdr = (Elf_Shdr *)mmap(NULL, (size_t)shdr_size, + PROT_READ, 0, fd, (off_t) ehdr.e_shoff); + if (shdr == (Elf_Shdr *)-1) return (-1); - shdr = (Elf_Shdr *)base; /* * Find the symbol table entry and it's corresponding @@ -292,10 +296,13 @@ __elf_fdnlist(fd, list) } } + /* Flush the section header table */ + munmap((caddr_t)shdr, shdr_size); + /* Check for files too large to mmap. */ if (symstrsize > SIZE_T_MAX) { errno = EFBIG; - goto done; + return (-1); } /* * Map string table into our address space. This gives us @@ -303,11 +310,10 @@ __elf_fdnlist(fd, list) * making the memory allocation permanent as with malloc/free * (i.e., munmap will return it to the system). */ - base = mmap(NULL, (size_t)symstrsize, PROT_READ, 0, fd, - (off_t)symstroff); - if (base == MAP_FAILED) - goto done; - strtab = (char *)base; + strtab = mmap(NULL, (size_t)symstrsize, PROT_READ, 0, fd, + (off_t) symstroff); + if (strtab == (char *)-1) + return (-1); /* * clean out any left-over information for all valid entries. @@ -329,6 +335,7 @@ __elf_fdnlist(fd, list) } /* Don't process any further if object is stripped. */ + /* ELFism - dunno if stripped by looking at header */ if (symoff == 0) goto done; @@ -337,24 +344,43 @@ __elf_fdnlist(fd, list) goto done; } - while (symsize > 0 && nent > 0) { + while (symsize > 0) { cc = MIN(symsize, sizeof(sbuf)); if (read(fd, sbuf, cc) != cc) break; symsize -= cc; - for (s = sbuf; cc > 0 && nent > 0; ++s, cc -= sizeof(*s)) { - char *name; - struct nlist *p; + for (s = sbuf; cc > 0; ++s, cc -= sizeof(*s)) { + register int soff = s->st_name; - name = strtab + s->st_name; - if (name[0] == '\0') + if (soff == 0) continue; for (p = list; !ISLAST(p); p++) { if ((p->n_un.n_name[0] == '_' && - strcmp(name, p->n_un.n_name+1) == 0) - || strcmp(name, p->n_un.n_name) == 0) { - elf_sym_to_nlist(p, s, shdr, - ehdr.e_shnum); + !strcmp(&strtab[soff], p->n_un.n_name+1)) + || !strcmp(&strtab[soff], p->n_un.n_name)) { + p->n_value = s->st_value; + + /* XXX - type conversion */ + /* is pretty rude. */ + switch(ELF(ST_TYPE)(s->st_info)) { + case STT_NOTYPE: + p->n_type = N_UNDF; + break; + case STT_OBJECT: + p->n_type = N_DATA; + break; + case STT_FUNC: + p->n_type = N_TEXT; + break; + case STT_FILE: + p->n_type = N_FN; + break; + } + if (ELF(ST_BIND)(s->st_info) == + STB_LOCAL) + p->n_type = N_EXT; + p->n_desc = 0; + p->n_other = 0; if (--nent <= 0) break; } @@ -362,52 +388,8 @@ __elf_fdnlist(fd, list) } } done: - errsave = errno; - if (strtab != NULL) - munmap(strtab, symstrsize); - if (shdr != NULL) - munmap(shdr, shdr_size); - errno = errsave; - return (nent); -} + munmap(strtab, symstrsize); -/* - * Convert an Elf_Sym into an nlist structure. This fills in only the - * n_value and n_type members. - */ -static void -elf_sym_to_nlist(nl, s, shdr, shnum) - struct nlist *nl; - Elf_Sym *s; - Elf_Shdr *shdr; - int shnum; -{ - nl->n_value = s->st_value; - - switch (s->st_shndx) { - case SHN_UNDEF: - case SHN_COMMON: - nl->n_type = N_UNDF; - break; - case SHN_ABS: - nl->n_type = ELF_ST_TYPE(s->st_info) == STT_FILE ? - N_FN : N_ABS; - break; - default: - if (s->st_shndx >= shnum) - nl->n_type = N_UNDF; - else { - Elf_Shdr *sh = shdr + s->st_shndx; - - nl->n_type = sh->sh_type == SHT_PROGBITS ? - (sh->sh_flags & SHF_WRITE ? N_DATA : N_TEXT) : - (sh->sh_type == SHT_NOBITS ? N_BSS : N_UNDF); - } - break; - } - - if (ELF_ST_BIND(s->st_info) == STB_GLOBAL || - ELF_ST_BIND(s->st_info) == STB_WEAK) - nl->n_type |= N_EXT; + return (nent); } #endif /* _NLIST_DO_ELF */ diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3 index 600f5d085aad0..c4278e5f3e388 100644 --- a/lib/libc/gen/popen.3 +++ b/lib/libc/gen/popen.3 @@ -53,19 +53,16 @@ function a process by creating a bidirectional pipe forking, and invoking the shell. -Any streams opened by previous -.Fn popen -calls in the parent process are closed in the new child process. Historically, -.Fn popen +.Nm popen was implemented with a unidirectional pipe; hence many implementations of -.Fn popen +.Nm popen only allow the .Fa type argument to specify reading or writing, not both. Since -.Fn popen +.Nm popen is now implemented using a bidirectional pipe, the .Fa type argument may request a bidirectional data flow. diff --git a/lib/libc/gen/psignal.3 b/lib/libc/gen/psignal.3 index aa78732d55aef..773759c1d89c9 100644 --- a/lib/libc/gen/psignal.3 +++ b/lib/libc/gen/psignal.3 @@ -57,9 +57,7 @@ If the argument .Fa s is .Pf non- Dv NULL -and does not point to the null character, -.Fa s -is written to the standard error file descriptor +it is written to the standard error file descriptor prior to the message string, immediately followed by a colon and a space. If the signal number is not recognized diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c index 96eab9d45d14a..b7e7ab66761ab 100644 --- a/lib/libc/gen/psignal.c +++ b/lib/libc/gen/psignal.c @@ -49,13 +49,15 @@ psignal(sig, s) const char *s; { register const char *c; + register int n; if (sig < NSIG) c = sys_siglist[sig]; else c = "Unknown signal"; - if (s != NULL && *s != '\0') { - (void)write(STDERR_FILENO, s, strlen(s)); + n = strlen(s); + if (n) { + (void)write(STDERR_FILENO, s, n); (void)write(STDERR_FILENO, ": ", 2); } (void)write(STDERR_FILENO, c, strlen(c)); diff --git a/lib/libc/gen/setmode.3 b/lib/libc/gen/setmode.3 index bc38fd3e11938..4c85b30e2a383 100644 --- a/lib/libc/gen/setmode.3 +++ b/lib/libc/gen/setmode.3 @@ -81,19 +81,10 @@ is to modify future file modes correctly. .Pp If the mode passed to .Fn setmode -is invalid or if memory cannot be allocated for the return value, +is invalid, .Fn setmode returns .Dv NULL . -.Pp -The value returned from -.Fn setmode -is obtained from -.Fn malloc -and should be returned to the system with -.Fn free -when the program is done with it, generally after a call to -.Fn getmode . .Sh ERRORS The .Fn setmode diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 index 02a185ca848ae..30e8e83eb8791 100644 --- a/lib/libc/gen/sysctl.3 +++ b/lib/libc/gen/sysctl.3 @@ -667,10 +667,9 @@ If the amount of free and cache memory falls below this value, the pageout daemon will enter "memory conserving mode" to avoid deadlock. .El .Sh RETURN VALUES +If the call to .Fn sysctl -and -.Fn sysctlbyname -return 0 when successful. +is successful, the number of bytes copied out is returned. Otherwise \-1 is returned and .Va errno is set appropriately. diff --git a/lib/libc/gen/sysctl.c b/lib/libc/gen/sysctl.c index 19709d5932e98..cb7448af32439 100644 --- a/lib/libc/gen/sysctl.c +++ b/lib/libc/gen/sysctl.c @@ -66,20 +66,16 @@ sysctl(name, namelen, oldp, oldlenp, newp, newlen) switch (name[1]) { case USER_CS_PATH: - if (oldp && *oldlenp < sizeof(_PATH_STDPATH)) { - errno = ENOMEM; - return -1; - } + if (oldp && *oldlenp < sizeof(_PATH_STDPATH)) + return (ENOMEM); *oldlenp = sizeof(_PATH_STDPATH); if (oldp != NULL) memmove(oldp, _PATH_STDPATH, sizeof(_PATH_STDPATH)); return (0); } - if (oldp && *oldlenp < sizeof(int)) { - errno = ENOMEM; - return (-1); - } + if (oldp && *oldlenp < sizeof(int)) + return (ENOMEM); *oldlenp = sizeof(int); if (oldp == NULL) return (0); diff --git a/lib/libc/gen/tzset.3 b/lib/libc/gen/tzset.3 index 5d83f335f525b..3c5b27650baec 100644 --- a/lib/libc/gen/tzset.3 +++ b/lib/libc/gen/tzset.3 @@ -137,7 +137,7 @@ is required; if is missing, then summer time does not apply in this locale. Upper and lowercase letters are explicitly allowed. Any characters except a leading colon -.Pq Ql \: , +.Pq Ql : , digits, comma .Pq Ql \&, , minus @@ -284,7 +284,7 @@ values in .El .Pp For compatibility with System V Release 3.1, a semicolon -.Pq Ql \; +.Pq Ql ; may be used to separate the .Em rule from the rest of the specification. |
