Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),

just use _foo() <-- foo().  In the case of a libpthread that doesn't do
call conversion (such as linuxthreads and our upcoming libpthread), this
is adequate.  In the case of libc_r, we still need three names, which are
now _thread_sys_foo() <-- _foo() <-- foo().

Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(),
nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo().

Remove all internal libc usage of: creat(), pause(), sleep(), system(),
tcdrain(), wait(), and waitpid().

Make thread cancellation fully POSIX-compliant.

Suggested by:	deischen
This commit is contained in:
Jason Evans 2000-01-27 23:07:25 +00:00
parent 072229cdbb
commit 9233c4d942
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56698
196 changed files with 2044 additions and 571 deletions

View File

@ -47,7 +47,7 @@ LLABEL(name,1):
#define SYSCALL(name) \
LEAF(name,0); /* XXX # of args? */ \
WEAK_ALIAS(__CONCAT(_libc_,name), name); \
WEAK_ALIAS(__CONCAT(_,name), name); \
CALLSYS_ERROR(name)
#define SYSCALL_NOERROR(name) \
@ -68,7 +68,7 @@ END(name)
#define PSEUDO(label,name) \
LEAF(label,0); /* XXX # of args? */ \
WEAK_ALIAS(__CONCAT(_libc_,name), name); \
WEAK_ALIAS(__CONCAT(_,name), name); \
CALLSYS_ERROR(name); \
RET; \
END(label);
@ -104,6 +104,7 @@ END(___CONCAT(_thread_sys_,name))
#define PSYSCALL(name) \
PLEAF(name,0); /* XXX # of args? */ \
WEAK_ALIAS(__CONCAT(_thread_sys_,name), name); \
CALLSYS_ERROR(name)
#define PRSYSCALL(name) \
@ -114,6 +115,7 @@ PEND(name)
#define PPSEUDO(label,name) \
PLEAF(label,0); /* XXX # of args? */ \
WEAK_ALIAS(__CONCAT(_thread_sys_,name), name); \
CALLSYS_ERROR(name); \
RET; \
PEND(label)

View File

@ -43,18 +43,15 @@
#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
ENTRY(__CONCAT(_,x)); \
.weak CNAME(__CONCAT(_libc_,x)); \
.set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_libc_,x)); \
.set CNAME(x),CNAME(__CONCAT(_,x)); \
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
#define RSYSCALL(x) SYSCALL(x); ret
#define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \
.weak CNAME(__CONCAT(_libc_,x)); \
.set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_libc_,x)); \
.set CNAME(x),CNAME(__CONCAT(_,x)); \
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
/* gas messes up offset -- although we don't currently need it, do for BCS */
@ -76,9 +73,13 @@
*/
#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
ENTRY(__CONCAT(_thread_sys_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
#define PRSYSCALL(x) PSYSCALL(x); ret
#define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
#else
/*

View File

@ -48,8 +48,7 @@ __creat(path, mode)
mode_t mode;
#endif
{
return(_libc_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode));
return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode));
}
__weak_reference(__creat, _libc_creat);
__weak_reference(_libc_creat, creat);
__weak_reference(__creat, creat);

View File

@ -109,5 +109,5 @@ sigpause(mask)
sigemptyset(&set);
set.__bits[0] = mask;
return (_libc_sigsuspend(&set));
return (_sigsuspend(&set));
}

View File

@ -105,7 +105,7 @@ __bt_close(dbp)
fd = t->bt_fd;
free(t);
free(dbp);
return (_libc_close(fd) ? RET_ERROR : RET_SUCCESS);
return (_close(fd) ? RET_ERROR : RET_SUCCESS);
}
/*

View File

@ -203,7 +203,7 @@ __bt_open(fname, flags, mode, openinfo, dflags)
goto einval;
}
if ((t->bt_fd = _libc_open(fname, flags, mode)) < 0)
if ((t->bt_fd = _open(fname, flags, mode)) < 0)
goto err;
} else {
@ -214,13 +214,13 @@ __bt_open(fname, flags, mode, openinfo, dflags)
F_SET(t, B_INMEM);
}
if (_libc_fcntl(t->bt_fd, F_SETFD, 1) == -1)
if (_fcntl(t->bt_fd, F_SETFD, 1) == -1)
goto err;
if (fstat(t->bt_fd, &sb))
goto err;
if (sb.st_size) {
if ((nr = _libc_read(t->bt_fd, &m, sizeof(BTMETA))) < 0)
if ((nr = _read(t->bt_fd, &m, sizeof(BTMETA))) < 0)
goto err;
if (nr != sizeof(BTMETA))
goto eftype;
@ -336,7 +336,7 @@ err: if (t) {
if (t->bt_dbp)
free(t->bt_dbp);
if (t->bt_fd != -1)
(void)_libc_close(t->bt_fd);
(void)_close(t->bt_fd);
free(t);
}
return (NULL);

View File

@ -130,7 +130,7 @@ __hash_open(file, flags, mode, info, dflags)
new_table = 1;
}
if (file) {
if ((hashp->fp = _libc_open(file, flags, mode)) == -1)
if ((hashp->fp = _open(file, flags, mode)) == -1)
RETURN_ERROR(errno, error0);
/* if the .db file is empty, and we had permission to create
@ -139,7 +139,7 @@ __hash_open(file, flags, mode, info, dflags)
fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
new_table = 1;
(void)_libc_fcntl(hashp->fp, F_SETFD, 1);
(void)_fcntl(hashp->fp, F_SETFD, 1);
}
if (new_table) {
if (!(hashp = init_hash(hashp, file, (HASHINFO *)info)))
@ -151,7 +151,7 @@ __hash_open(file, flags, mode, info, dflags)
else
hashp->hash = __default_hash;
hdrsize = _libc_read(hashp->fp, &hashp->hdr, sizeof(HASHHDR));
hdrsize = _read(hashp->fp, &hashp->hdr, sizeof(HASHHDR));
#if BYTE_ORDER == LITTLE_ENDIAN
swap_header(hashp);
#endif
@ -242,7 +242,7 @@ __hash_open(file, flags, mode, info, dflags)
error1:
if (hashp != NULL)
(void)_libc_close(hashp->fp);
(void)_close(hashp->fp);
error0:
free(hashp);
@ -440,7 +440,7 @@ hdestroy(hashp)
free(hashp->mapp[i]);
if (hashp->fp != -1)
(void)_libc_close(hashp->fp);
(void)_close(hashp->fp);
free(hashp);
@ -509,7 +509,7 @@ flush_meta(hashp)
swap_header_copy(&hashp->hdr, whdrp);
#endif
if ((lseek(fp, (off_t)0, SEEK_SET) == -1) ||
((wsize = _libc_write(fp, whdrp, sizeof(HASHHDR))) == -1))
((wsize = _write(fp, whdrp, sizeof(HASHHDR))) == -1))
return (-1);
else
if (wsize != sizeof(HASHHDR)) {

View File

@ -539,7 +539,7 @@ __get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap)
else
page = OADDR_TO_PAGE(bucket);
if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) ||
((rsize = _libc_read(fd, p, size)) == -1))
((rsize = _read(fd, p, size)) == -1))
return (-1);
bp = (u_int16_t *)p;
if (!rsize)
@ -610,7 +610,7 @@ __put_page(hashp, p, bucket, is_bucket, is_bitmap)
else
page = OADDR_TO_PAGE(bucket);
if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) ||
((wsize = _libc_write(fd, p, size)) == -1))
((wsize = _write(fd, p, size)) == -1))
/* Errno is set */
return (-1);
if (wsize != size) {
@ -714,8 +714,7 @@ overflow_page(hashp)
#define OVMSG "HASH: Out of overflow pages. Increase page size\n"
if (offset > SPLITMASK) {
if (++splitnum >= NCACHED) {
(void)_libc_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) -
1);
(void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1);
return (0);
}
hashp->OVFL_POINT = splitnum;
@ -728,8 +727,7 @@ overflow_page(hashp)
if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) {
free_page++;
if (free_page >= NCACHED) {
(void)_libc_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) -
1);
(void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1);
return (0);
}
/*
@ -753,7 +751,7 @@ overflow_page(hashp)
offset++;
if (offset > SPLITMASK) {
if (++splitnum >= NCACHED) {
(void)_libc_write(STDERR_FILENO, OVMSG,
(void)_write(STDERR_FILENO, OVMSG,
sizeof(OVMSG) - 1);
return (0);
}
@ -871,7 +869,7 @@ open_temp(hashp)
(void)sigprocmask(SIG_BLOCK, &set, &oset);
if ((hashp->fp = mkstemp(namestr)) != -1) {
(void)unlink(namestr);
(void)_libc_fcntl(hashp->fp, F_SETFD, 1);
(void)_fcntl(hashp->fp, F_SETFD, 1);
}
(void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
return (hashp->fp != -1 ? 0 : -1);

View File

@ -207,7 +207,7 @@ mpool_get(mp, pgno, flags)
off = mp->pagesize * pgno;
if (lseek(mp->fd, off, SEEK_SET) != off)
return (NULL);
if ((nr = _libc_read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) {
if ((nr = _read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) {
if (nr >= 0)
errno = EFTYPE;
return (NULL);
@ -299,7 +299,7 @@ mpool_sync(mp)
return (RET_ERROR);
/* Sync the file descriptor. */
return (_libc_fsync(mp->fd) ? RET_ERROR : RET_SUCCESS);
return (_fsync(mp->fd) ? RET_ERROR : RET_SUCCESS);
}
/*
@ -382,7 +382,7 @@ mpool_write(mp, bp)
off = mp->pagesize * bp->pgno;
if (lseek(mp->fd, off, SEEK_SET) != off)
return (RET_ERROR);
if (_libc_write(mp->fd, bp->page, mp->pagesize) != mp->pagesize)
if (_write(mp->fd, bp->page, mp->pagesize) != mp->pagesize)
return (RET_ERROR);
bp->flags &= ~MPOOL_DIRTY;

View File

@ -86,7 +86,7 @@ __rec_close(dbp)
if (fclose(t->bt_rfp))
status = RET_ERROR;
} else
if (_libc_close(t->bt_rfd))
if (_close(t->bt_rfd))
status = RET_ERROR;
if (__bt_close(dbp) == RET_ERROR)
@ -152,7 +152,7 @@ __rec_sync(dbp, flags)
*/
status = (dbp->seq)(dbp, &key, &data, R_FIRST);
while (status == RET_SUCCESS) {
if (_libc_write(t->bt_rfd, data.data, data.size) !=
if (_write(t->bt_rfd, data.data, data.size) !=
data.size)
return (RET_ERROR);
status = (dbp->seq)(dbp, &key, &data, R_NEXT);

View File

@ -68,7 +68,7 @@ __rec_open(fname, flags, mode, openinfo, dflags)
int rfd, sverrno;
/* Open the user's file -- if this fails, we're done. */
if (fname != NULL && (rfd = _libc_open(fname, flags, mode)) < 0)
if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0)
return (NULL);
/* Create a btree in memory (backed by disk). */
@ -215,7 +215,7 @@ err: sverrno = errno;
if (dbp != NULL)
(void)__bt_close(dbp);
if (fname != NULL)
(void)_libc_close(rfd);
(void)_close(rfd);
errno = sverrno;
return (NULL);
}

View File

@ -84,10 +84,10 @@ arc4_stir(as)
gettimeofday(&rdat.tv, NULL);
rdat.pid = getpid();
fd = _libc_open("/dev/urandom", O_RDONLY, 0);
fd = _open("/dev/urandom", O_RDONLY, 0);
if (fd >= 0) {
(void) _libc_read(fd, rdat.rnd, sizeof(rdat.rnd));
_libc_close(fd);
(void) _read(fd, rdat.rnd, sizeof(rdat.rnd));
_close(fd);
}
/* fd < 0? Ah, what the heck. We'll just take whatever was on the
* stack... */

View File

@ -60,5 +60,5 @@ closedir(dirp)
free((void *)dirp->dd_buf);
free((void *)dirp);
_reclaim_telldir(dirp);
return(_libc_close(fd));
return(_close(fd));
}

View File

@ -62,12 +62,12 @@ daemon(nochdir, noclose)
if (!nochdir)
(void)chdir("/");
if (!noclose && (fd = _libc_open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
if (!noclose && (fd = _open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
(void)dup2(fd, STDIN_FILENO);
(void)dup2(fd, STDOUT_FILENO);
(void)dup2(fd, STDERR_FILENO);
if (fd > 2)
(void)_libc_close(fd);
(void)_close(fd);
}
return (0);
}

View File

@ -249,9 +249,9 @@ execvp(name, argv)
* the user may execute the wrong program.
*/
if (lp + ln + 2 > sizeof(buf)) {
(void)_libc_write(STDERR_FILENO, "execvp: ", 8);
(void)_libc_write(STDERR_FILENO, p, lp);
(void)_libc_write(STDERR_FILENO, ": path too long\n",
(void)_write(STDERR_FILENO, "execvp: ", 8);
(void)_write(STDERR_FILENO, p, lp);
(void)_write(STDERR_FILENO, ": path too long\n",
16);
continue;
}

View File

@ -253,12 +253,12 @@ error(err)
char *p;
char num[30];
(void)_libc_write(STDERR_FILENO, "fstab: ", 7);
(void)_libc_write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1);
(void)_libc_write(STDERR_FILENO, ":", 1);
(void)_write(STDERR_FILENO, "fstab: ", 7);
(void)_write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1);
(void)_write(STDERR_FILENO, ":", 1);
sprintf(num, "%d: ", LineNo);
(void)_libc_write(STDERR_FILENO, num, strlen(num));
(void)_write(STDERR_FILENO, num, strlen(num));
p = strerror(err);
(void)_libc_write(STDERR_FILENO, p, strlen(p));
(void)_libc_write(STDERR_FILENO, "\n", 1);
(void)_write(STDERR_FILENO, p, strlen(p));
(void)_write(STDERR_FILENO, "\n", 1);
}

View File

@ -178,8 +178,7 @@ fts_open(argv, options, compar)
* and ".." are all fairly nasty problems. Note, if we can't get the
* descriptor we run anyway, just more slowly.
*/
if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _libc_open(".", O_RDONLY, 0))
< 0)
if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0)
SET(FTS_NOCHDIR);
return (sp);
@ -248,7 +247,7 @@ fts_close(sp)
/* Return to original directory, save errno if necessary. */
if (!ISSET(FTS_NOCHDIR)) {
saved_errno = fchdir(sp->fts_rfd) ? errno : 0;
(void)_libc_close(sp->fts_rfd);
(void)_close(sp->fts_rfd);
/* Set errno and return. */
if (saved_errno != 0) {
@ -308,7 +307,7 @@ fts_read(sp)
(p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
p->fts_info = fts_stat(sp, p, 1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd = _libc_open(".", O_RDONLY, 0)) < 0) {
if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
} else
@ -323,7 +322,7 @@ fts_read(sp)
if (instr == FTS_SKIP ||
(ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) {
if (p->fts_flags & FTS_SYMFOLLOW)
(void)_libc_close(p->fts_symfd);
(void)_close(p->fts_symfd);
if (sp->fts_child) {
fts_lfree(sp->fts_child);
sp->fts_child = NULL;
@ -398,7 +397,7 @@ next: tmp = p;
p->fts_info = fts_stat(sp, p, 1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd =
_libc_open(".", O_RDONLY, 0)) < 0) {
_open(".", O_RDONLY, 0)) < 0) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
} else
@ -443,12 +442,12 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
} else if (p->fts_flags & FTS_SYMFOLLOW) {
if (FCHDIR(sp, p->fts_symfd)) {
saved_errno = errno;
(void)_libc_close(p->fts_symfd);
(void)_close(p->fts_symfd);
errno = saved_errno;
SET(FTS_STOP);
return (NULL);
}
(void)_libc_close(p->fts_symfd);
(void)_close(p->fts_symfd);
} else if (!(p->fts_flags & FTS_DONTCHDIR)) {
if (CHDIR(sp, "..")) {
SET(FTS_STOP);
@ -540,12 +539,12 @@ fts_children(sp, instr)
ISSET(FTS_NOCHDIR))
return (sp->fts_child = fts_build(sp, instr));
if ((fd = _libc_open(".", O_RDONLY, 0)) < 0)
if ((fd = _open(".", O_RDONLY, 0)) < 0)
return (NULL);
sp->fts_child = fts_build(sp, instr);
if (fchdir(fd))
return (NULL);
(void)_libc_close(fd);
(void)_close(fd);
return (sp->fts_child);
}
@ -1094,7 +1093,7 @@ fts_safe_changedir(sp, p, fd)
newfd = fd;
if (ISSET(FTS_NOCHDIR))
return (0);
if (fd < 0 && (newfd = _libc_open(p->fts_accpath, O_RDONLY, 0)) < 0)
if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0)
return (-1);
if (fstat(newfd, &sb)) {
ret = -1;
@ -1109,7 +1108,7 @@ fts_safe_changedir(sp, p, fd)
bail:
oerrno = errno;
if (fd < 0)
(void)_libc_close(newfd);
(void)_close(newfd);
errno = oerrno;
return (ret);
}

View File

@ -178,8 +178,7 @@ fts_open(argv, options, compar)
* and ".." are all fairly nasty problems. Note, if we can't get the
* descriptor we run anyway, just more slowly.
*/
if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _libc_open(".", O_RDONLY, 0))
< 0)
if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0)
SET(FTS_NOCHDIR);
return (sp);
@ -248,7 +247,7 @@ fts_close(sp)
/* Return to original directory, save errno if necessary. */
if (!ISSET(FTS_NOCHDIR)) {
saved_errno = fchdir(sp->fts_rfd) ? errno : 0;
(void)_libc_close(sp->fts_rfd);
(void)_close(sp->fts_rfd);
/* Set errno and return. */
if (saved_errno != 0) {
@ -308,7 +307,7 @@ fts_read(sp)
(p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
p->fts_info = fts_stat(sp, p, 1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd = _libc_open(".", O_RDONLY, 0)) < 0) {
if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
} else
@ -323,7 +322,7 @@ fts_read(sp)
if (instr == FTS_SKIP ||
(ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) {
if (p->fts_flags & FTS_SYMFOLLOW)
(void)_libc_close(p->fts_symfd);
(void)_close(p->fts_symfd);
if (sp->fts_child) {
fts_lfree(sp->fts_child);
sp->fts_child = NULL;
@ -398,7 +397,7 @@ next: tmp = p;
p->fts_info = fts_stat(sp, p, 1);
if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
if ((p->fts_symfd =
_libc_open(".", O_RDONLY, 0)) < 0) {
_open(".", O_RDONLY, 0)) < 0) {
p->fts_errno = errno;
p->fts_info = FTS_ERR;
} else
@ -443,12 +442,12 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
} else if (p->fts_flags & FTS_SYMFOLLOW) {
if (FCHDIR(sp, p->fts_symfd)) {
saved_errno = errno;
(void)_libc_close(p->fts_symfd);
(void)_close(p->fts_symfd);
errno = saved_errno;
SET(FTS_STOP);
return (NULL);
}
(void)_libc_close(p->fts_symfd);
(void)_close(p->fts_symfd);
} else if (!(p->fts_flags & FTS_DONTCHDIR)) {
if (CHDIR(sp, "..")) {
SET(FTS_STOP);
@ -540,12 +539,12 @@ fts_children(sp, instr)
ISSET(FTS_NOCHDIR))
return (sp->fts_child = fts_build(sp, instr));
if ((fd = _libc_open(".", O_RDONLY, 0)) < 0)
if ((fd = _open(".", O_RDONLY, 0)) < 0)
return (NULL);
sp->fts_child = fts_build(sp, instr);
if (fchdir(fd))
return (NULL);
(void)_libc_close(fd);
(void)_close(fd);
return (sp->fts_child);
}
@ -1094,7 +1093,7 @@ fts_safe_changedir(sp, p, fd)
newfd = fd;
if (ISSET(FTS_NOCHDIR))
return (0);
if (fd < 0 && (newfd = _libc_open(p->fts_accpath, O_RDONLY, 0)) < 0)
if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0)
return (-1);
if (fstat(newfd, &sb)) {
ret = -1;
@ -1109,7 +1108,7 @@ fts_safe_changedir(sp, p, fd)
bail:
oerrno = errno;
if (fd < 0)
(void)_libc_close(newfd);
(void)_close(newfd);
errno = oerrno;
return (ret);
}

View File

@ -268,7 +268,7 @@ getent(cap, len, db_array, fd, name, depth, nfield)
*cap = cbuf;
return (retval);
} else {
fd = _libc_open(*db_p, O_RDONLY, 0);
fd = _open(*db_p, O_RDONLY, 0);
if (fd < 0)
continue;
myfd = 1;
@ -303,10 +303,10 @@ getent(cap, len, db_array, fd, name, depth, nfield)
if (bp >= b_end) {
int n;
n = _libc_read(fd, buf, sizeof(buf));
n = _read(fd, buf, sizeof(buf));
if (n <= 0) {
if (myfd)
(void)_libc_close(fd);
(void)_close(fd);
if (n < 0) {
free(record);
return (-2);
@ -345,7 +345,7 @@ getent(cap, len, db_array, fd, name, depth, nfield)
if (record == NULL) {
errno = ENOMEM;
if (myfd)
(void)_libc_close(fd);
(void)_close(fd);
return (-2);
}
r_end = record + newsize;
@ -435,7 +435,7 @@ tc_exp: {
/* an error */
if (iret < -1) {
if (myfd)
(void)_libc_close(fd);
(void)_close(fd);
free(record);
return (iret);
}
@ -485,7 +485,7 @@ tc_exp: {
if (record == NULL) {
errno = ENOMEM;
if (myfd)
(void)_libc_close(fd);
(void)_close(fd);
free(icap);
return (-2);
}
@ -517,7 +517,7 @@ tc_exp: {
* return capability, length and success.
*/
if (myfd)
(void)_libc_close(fd);
(void)_close(fd);
*len = rp - record - 1; /* don't count NUL */
if (r_end > rp)
if ((record =

View File

@ -86,7 +86,7 @@ getpass(prompt)
if (p < buf + _PASSWORD_LEN)
*p++ = ch;
*p = '\0';
(void)_libc_write(fileno(outfp), "\n", 1);
(void)_write(fileno(outfp), "\n", 1);
(void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &oterm);
(void)sigprocmask(SIG_SETMASK, &oset, NULL);

View File

@ -75,7 +75,7 @@ lockf(filedes, function, size)
break;
case F_TEST:
fl.l_type = F_WRLCK;
if (_libc_fcntl(filedes, F_GETLK, &fl) == -1)
if (_fcntl(filedes, F_GETLK, &fl) == -1)
return (-1);
if (fl.l_type == F_UNLCK || fl.l_pid == getpid())
return (0);
@ -88,5 +88,5 @@ lockf(filedes, function, size)
/* NOTREACHED */
}
return (_libc_fcntl(filedes, cmd, &fl));
return (_fcntl(filedes, cmd, &fl));
}

View File

@ -66,11 +66,11 @@ nlist(name, list)
{
int fd, n;
fd = _libc_open(name, O_RDONLY, 0);
fd = _open(name, O_RDONLY, 0);
if (fd < 0)
return (-1);
n = __fdnlist(fd, list);
(void)_libc_close(fd);
(void)_close(fd);
return (n);
}
@ -255,7 +255,7 @@ __elf_fdnlist(fd, list)
/* Make sure obj is OK */
if (lseek(fd, (off_t)0, SEEK_SET) == -1 ||
_libc_read(fd, &ehdr, sizeof(Elf_Ehdr)) != sizeof(Elf_Ehdr) ||
_read(fd, &ehdr, sizeof(Elf_Ehdr)) != sizeof(Elf_Ehdr) ||
!__elf_is_okay__(&ehdr) ||
fstat(fd, &st) < 0)
return (-1);
@ -339,7 +339,7 @@ __elf_fdnlist(fd, list)
while (symsize > 0 && nent > 0) {
cc = MIN(symsize, sizeof(sbuf));
if (_libc_read(fd, sbuf, cc) != cc)
if (_read(fd, sbuf, cc) != cc)
break;
symsize -= cc;
for (s = sbuf; cc > 0 && nent > 0; ++s, cc -= sizeof(*s)) {

View File

@ -80,7 +80,7 @@ __opendir2(name, flags)
errno = ENOTDIR;
return (NULL);
}
if ((fd = _libc_open(name, O_RDONLY | O_NONBLOCK)) == -1)
if ((fd = _open(name, O_RDONLY | O_NONBLOCK)) == -1)
return (NULL);
dirp = NULL;
if (fstat(fd, &statb) != 0)
@ -89,7 +89,7 @@ __opendir2(name, flags)
errno = ENOTDIR;
goto fail;
}
if (_libc_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 ||
if (_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 ||
(dirp = malloc(sizeof(DIR))) == NULL)
goto fail;
@ -163,8 +163,8 @@ __opendir2(name, flags)
* which has also been read -- see fts.c.
*/
if (flags & DTF_REWIND) {
(void)_libc_close(fd);
if ((fd = _libc_open(name, O_RDONLY)) == -1) {
(void)_close(fd);
if ((fd = _open(name, O_RDONLY)) == -1) {
saved_errno = errno;
free(buf);
free(dirp);
@ -270,7 +270,7 @@ __opendir2(name, flags)
fail:
saved_errno = errno;
free(dirp);
(void)_libc_close(fd);
(void)_close(fd);
errno = saved_errno;
return (NULL);
}

View File

@ -49,5 +49,4 @@ __pause()
return sigpause(sigblock(0L));
}
__weak_reference(__pause, _libc_pause);
__weak_reference(_libc_pause, pause);
__weak_reference(__pause, pause);

View File

@ -85,8 +85,8 @@ popen(command, type)
return (NULL);
if ((cur = malloc(sizeof(struct pid))) == NULL) {
(void)_libc_close(pdes[0]);
(void)_libc_close(pdes[1]);
(void)_close(pdes[0]);
(void)_close(pdes[1]);
return (NULL);
}
@ -97,8 +97,8 @@ popen(command, type)
switch (pid = vfork()) {
case -1: /* Error. */
(void)_libc_close(pdes[0]);
(void)_libc_close(pdes[1]);
(void)_close(pdes[0]);
(void)_close(pdes[1]);
free(cur);
return (NULL);
/* NOTREACHED */
@ -112,10 +112,10 @@ popen(command, type)
* the compiler is free to corrupt all the local
* variables.
*/
(void)_libc_close(pdes[0]);
(void)_close(pdes[0]);
if (pdes[1] != STDOUT_FILENO) {
(void)dup2(pdes[1], STDOUT_FILENO);
(void)_libc_close(pdes[1]);
(void)_close(pdes[1]);
if (twoway)
(void)dup2(STDOUT_FILENO, STDIN_FILENO);
} else if (twoway && (pdes[1] != STDIN_FILENO))
@ -123,12 +123,12 @@ popen(command, type)
} else {
if (pdes[0] != STDIN_FILENO) {
(void)dup2(pdes[0], STDIN_FILENO);
(void)_libc_close(pdes[0]);
(void)_close(pdes[0]);
}
(void)_libc_close(pdes[1]);
(void)_close(pdes[1]);
}
for (p = pidlist; p; p = p->next) {
(void)_libc_close(fileno(p->fp));
(void)_close(fileno(p->fp));
}
execve(_PATH_BSHELL, argv, environ);
_exit(127);
@ -138,10 +138,10 @@ popen(command, type)
/* Parent; assume fdopen can't fail. */
if (*type == 'r') {
iop = fdopen(pdes[0], type);
(void)_libc_close(pdes[1]);
(void)_close(pdes[1]);
} else {
iop = fdopen(pdes[1], type);
(void)_libc_close(pdes[0]);
(void)_close(pdes[0]);
}
/* Link into list of file descriptors. */
@ -177,7 +177,7 @@ pclose(iop)
(void)fclose(iop);
do {
pid = _libc_waitpid(cur->pid, &pstat, 0);
pid = _wait4(cur->pid, &pstat, 0, (struct rusage *)0);
} while (pid == -1 && errno == EINTR);
/* Remove the entry from the linked list. */

View File

@ -57,9 +57,9 @@ psignal(sig, s)
else
c = "Unknown signal";
if (s != NULL && *s != '\0') {
(void)_libc_write(STDERR_FILENO, s, strlen(s));
(void)_libc_write(STDERR_FILENO, ": ", 2);
(void)_write(STDERR_FILENO, s, strlen(s));
(void)_write(STDERR_FILENO, ": ", 2);
}
(void)_libc_write(STDERR_FILENO, c, strlen(c));
(void)_libc_write(STDERR_FILENO, "\n", 1);
(void)_write(STDERR_FILENO, c, strlen(c));
(void)_write(STDERR_FILENO, "\n", 1);
}

View File

@ -51,5 +51,5 @@ void
longjmperror()
{
#define ERRMSG "longjmp botch.\n"
(void)_libc_write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1);
(void)_write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1);
}

View File

@ -60,7 +60,7 @@ __sleep(seconds)
time_to_sleep.tv_sec = seconds;
time_to_sleep.tv_nsec = 0;
if (_libc_nanosleep(&time_to_sleep, &time_remaining) != -1)
if (_nanosleep(&time_to_sleep, &time_remaining) != -1)
return (0);
if (errno != EINTR)
return (seconds); /* best guess */
@ -68,5 +68,4 @@ __sleep(seconds)
(time_remaining.tv_nsec != 0)); /* round up */
}
__weak_reference(__sleep, _libc_sleep);
__weak_reference(_libc_sleep, sleep);
__weak_reference(__sleep, sleep);

View File

@ -260,7 +260,7 @@ vsyslog(pri, fmt, ap)
* is the one from the syslogd failure.
*/
if (LogStat & LOG_CONS &&
(fd = _libc_open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) {
(fd = _open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) {
struct iovec iov[2];
register struct iovec *v = iov;
@ -271,7 +271,7 @@ vsyslog(pri, fmt, ap)
v->iov_base = "\r\n";
v->iov_len = 2;
(void)writev(fd, iov, 2);
(void)_libc_close(fd);
(void)_close(fd);
}
}
static void
@ -283,7 +283,7 @@ disconnectlog()
* system services.
*/
if (LogFile != -1) {
_libc_close(LogFile);
_close(LogFile);
LogFile = -1;
}
connected = 0; /* retry connect */
@ -297,7 +297,7 @@ connectlog()
if (LogFile == -1) {
if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
return;
(void)_libc_fcntl(LogFile, F_SETFD, 1);
(void)_fcntl(LogFile, F_SETFD, 1);
}
if (LogFile != -1 && !connected) {
SyslogAddr.sun_len = sizeof(SyslogAddr);
@ -320,7 +320,7 @@ connectlog()
}
if (!connected) {
(void)_libc_close(LogFile);
(void)_close(LogFile);
LogFile = -1;
}
}
@ -346,7 +346,7 @@ openlog(ident, logstat, logfac)
void
closelog()
{
(void)_libc_close(LogFile);
(void)_close(LogFile);
LogFile = -1;
connected = 0;
}

View File

@ -195,8 +195,7 @@ __tcdrain(fd)
return (ioctl(fd, TIOCDRAIN, 0));
}
__weak_reference(__tcdrain, _libc_tcdrain);
__weak_reference(_libc_tcdrain, tcdrain);
__weak_reference(__tcdrain, tcdrain);
int
tcflush(fd, which)
@ -238,8 +237,7 @@ tcflow(fd, action)
if (tcgetattr(fd, &term) == -1)
return (-1);
c = term.c_cc[action == TCIOFF ? VSTOP : VSTART];
if (c != _POSIX_VDISABLE && _libc_write(fd, &c, sizeof(c)) ==
-1)
if (c != _POSIX_VDISABLE && _write(fd, &c, sizeof(c)) == -1)
return (-1);
return (0);
default:

View File

@ -50,5 +50,5 @@ usleep(useconds)
time_to_sleep.tv_nsec = (useconds % 1000000) * 1000;
time_to_sleep.tv_sec = useconds / 1000000;
return (_libc_nanosleep(&time_to_sleep, NULL));
return (_nanosleep(&time_to_sleep, NULL));
}

View File

@ -49,5 +49,4 @@ __wait(istat)
return (wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
}
__weak_reference(__wait, _libc_wait);
__weak_reference(_libc_wait, wait);
__weak_reference(__wait, wait);

View File

@ -55,5 +55,4 @@ __waitpid(pid, istat, options)
return (wait4(pid, istat, options, (struct rusage *)0));
}
__weak_reference(__waitpid, _libc_waitpid);
__weak_reference(_libc_waitpid, waitpid);
__weak_reference(__waitpid, waitpid);

View File

@ -62,7 +62,7 @@ static int s_scale;
/* see profil(2) where this is describe (incorrectly) */
#define SCALE_1_TO_1 0x10000L
#define ERR(s) _libc_write(2, s, sizeof(s))
#define ERR(s) _write(2, s, sizeof(s))
void moncontrol __P((int));
static int hertz __P((void));
@ -172,20 +172,20 @@ _mcleanup()
moncontrol(0);
snprintf(outname,sizeof(outname),"%s.gmon",__progname);
fd = _libc_open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666);
fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (fd < 0) {
warnx("_mcleanup: %s - %s",outname,strerror(errno));
return;
}
#ifdef DEBUG
log = _libc_open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664);
log = _open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664);
if (log < 0) {
perror("_mcleanup: gmon.log");
return;
}
len = sprintf(buf, "[mcleanup1] kcount 0x%x ssiz %d\n",
p->kcount, p->kcountsize);
_libc_write(log, buf, len);
_write(log, buf, len);
#endif
hdr = (struct gmonhdr *)&gmonhdr;
hdr->lpc = p->lowpc;
@ -193,8 +193,8 @@ _mcleanup()
hdr->ncnt = p->kcountsize + sizeof(gmonhdr);
hdr->version = GMONVERSION;
hdr->profrate = clockinfo.profhz;
_libc_write(fd, (char *)hdr, sizeof *hdr);
_libc_write(fd, p->kcount, p->kcountsize);
_write(fd, (char *)hdr, sizeof *hdr);
_write(fd, p->kcount, p->kcountsize);
endfrom = p->fromssize / sizeof(*p->froms);
for (fromindex = 0; fromindex < endfrom; fromindex++) {
if (p->froms[fromindex] == 0)
@ -209,15 +209,15 @@ _mcleanup()
"[mcleanup2] frompc 0x%x selfpc 0x%x count %d\n" ,
frompc, p->tos[toindex].selfpc,
p->tos[toindex].count);
_libc_write(log, buf, len);
_write(log, buf, len);
#endif
rawarc.raw_frompc = frompc;
rawarc.raw_selfpc = p->tos[toindex].selfpc;
rawarc.raw_count = p->tos[toindex].count;
_libc_write(fd, &rawarc, sizeof rawarc);
_write(fd, &rawarc, sizeof rawarc);
}
}
_libc_close(fd);
_close(fd);
}
/*

View File

@ -43,18 +43,15 @@
#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
ENTRY(__CONCAT(_,x)); \
.weak CNAME(__CONCAT(_libc_,x)); \
.set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_libc_,x)); \
.set CNAME(x),CNAME(__CONCAT(_,x)); \
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
#define RSYSCALL(x) SYSCALL(x); ret
#define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \
.weak CNAME(__CONCAT(_libc_,x)); \
.set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_libc_,x)); \
.set CNAME(x),CNAME(__CONCAT(_,x)); \
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
/* gas messes up offset -- although we don't currently need it, do for BCS */
@ -76,9 +73,13 @@
*/
#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
ENTRY(__CONCAT(_thread_sys_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
#define PRSYSCALL(x) PSYSCALL(x); ret
#define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \
.weak CNAME(x); \
.set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
#else
/*

View File

@ -177,14 +177,14 @@ __collate_err(int ex, const char *f)
int serrno = errno;
s = __progname;
_libc_write(STDERR_FILENO, s, strlen(s));
_libc_write(STDERR_FILENO, ": ", 2);
_write(STDERR_FILENO, s, strlen(s));
_write(STDERR_FILENO, ": ", 2);
s = f;
_libc_write(STDERR_FILENO, s, strlen(s));
_libc_write(STDERR_FILENO, ": ", 2);
_write(STDERR_FILENO, s, strlen(s));
_write(STDERR_FILENO, ": ", 2);
s = strerror(serrno);
_libc_write(STDERR_FILENO, s, strlen(s));
_libc_write(STDERR_FILENO, "\n", 1);
_write(STDERR_FILENO, s, strlen(s));
_write(STDERR_FILENO, "\n", 1);
exit(ex);
}

View File

@ -578,7 +578,7 @@ explore_null(pai, hostname, servname, res)
s = socket(pai->ai_family, SOCK_DGRAM, 0);
if (s < 0)
return 0;
_libc_close(s);
_close(s);
afd = find_afd(pai->ai_family);
if (afd == NULL)
return 0;

View File

@ -257,7 +257,7 @@ _ghbyname(const char *name, int af, int flags, int *errp)
* (or apropriate interval),
* because addresses will be dynamically assigned or deleted.
*/
_libc_close(s);
_close(s);
}
for (i = 0; i < MAXHOSTCONF; i++) {
@ -1184,21 +1184,21 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex)
(char *)&filter, sizeof(filter));
cc = sendmsg(s, &msg, 0);
if (cc < 0) {
_libc_close(s);
_close(s);
return NULL;
}
FD_SET(s, &s_fds);
for (;;) {
fds = s_fds;
if (select(s + 1, &fds, NULL, NULL, &tout) <= 0) {
_libc_close(s);
_close(s);
return NULL;
}
len = sizeof(sin6);
cc = recvfrom(s, buf, sizeof(buf), 0,
(struct sockaddr *)&sin6, &len);
if (cc <= 0) {
_libc_close(s);
_close(s);
return NULL;
}
if (cc < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr))
@ -1209,7 +1209,7 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex)
if (fr->icmp6_fqdn_type == ICMP6_FQDN_REPLY)
break;
}
_libc_close(s);
_close(s);
if (fr->icmp6_fqdn_cookie[1] != 0) {
/* rfc1788 type */
name = buf + sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr) + 4;

View File

@ -136,10 +136,10 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
freeaddrinfo(res);
return (-1);
}
_libc_fcntl(s, F_SETOWN, pid);
_fcntl(s, F_SETOWN, pid);
if (connect(s, ai->ai_addr, ai->ai_addrlen) >= 0)
break;
(void)_libc_close(s);
(void)_close(s);
if (errno == EADDRINUSE) {
lport--;
continue;
@ -166,7 +166,12 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
continue;
}
if (refused && timo <= 16) {
(void)_libc_sleep(timo);
struct timespec time_to_sleep, time_remaining;
time_to_sleep.tv_sec = timo;
time_to_sleep.tv_nsec = 0;
(void)_nanosleep(&time_to_sleep, &time_remaining);
timo *= 2;
ai = res;
refused = 0;
@ -179,7 +184,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
}
lport--;
if (fd2p == 0) {
_libc_write(s, "", 1);
_write(s, "", 1);
lport = 0;
} else {
char num[8];
@ -191,17 +196,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
goto bad;
listen(s2, 1);
(void)snprintf(num, sizeof(num), "%d", lport);
if (_libc_write(s, num, strlen(num)+1) != strlen(num)+1) {
if (_write(s, num, strlen(num)+1) != strlen(num)+1) {
(void)fprintf(stderr,
"rcmd: write (setting up stderr): %s\n",
strerror(errno));
(void)_libc_close(s2);
(void)_close(s2);
goto bad;
}
nfds = max(s, s2)+1;
if(nfds > FD_SETSIZE) {
fprintf(stderr, "rcmd: too many files\n");
(void)_libc_close(s2);
(void)_close(s2);
goto bad;
}
again:
@ -217,7 +222,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
else
(void)fprintf(stderr,
"select: protocol failure in circuit setup\n");
(void)_libc_close(s2);
(void)_close(s2);
goto bad;
}
s3 = accept(s2, (struct sockaddr *)&from, &len);
@ -239,10 +244,10 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
* down and check for the real auxiliary channel to connect.
*/
if (aport == 20) {
_libc_close(s3);
_close(s3);
goto again;
}
(void)_libc_close(s2);
(void)_close(s2);
if (s3 < 0) {
(void)fprintf(stderr,
"rcmd: accept: %s\n", strerror(errno));
@ -256,17 +261,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
goto bad2;
}
}
(void)_libc_write(s, locuser, strlen(locuser)+1);
(void)_libc_write(s, remuser, strlen(remuser)+1);
(void)_libc_write(s, cmd, strlen(cmd)+1);
if (_libc_read(s, &c, 1) != 1) {
(void)_write(s, locuser, strlen(locuser)+1);
(void)_write(s, remuser, strlen(remuser)+1);
(void)_write(s, cmd, strlen(cmd)+1);
if (_read(s, &c, 1) != 1) {
(void)fprintf(stderr,
"rcmd: %s: %s\n", *ahost, strerror(errno));
goto bad2;
}
if (c != 0) {
while (_libc_read(s, &c, 1) == 1) {
(void)_libc_write(STDERR_FILENO, &c, 1);
while (_read(s, &c, 1) == 1) {
(void)_write(STDERR_FILENO, &c, 1);
if (c == '\n')
break;
}
@ -277,9 +282,9 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
return (s);
bad2:
if (lport)
(void)_libc_close(*fd2p);
(void)_close(*fd2p);
bad:
(void)_libc_close(s);
(void)_close(s);
sigsetmask(oldmask);
freeaddrinfo(res);
return (-1);
@ -328,13 +333,13 @@ rresvport_af(alport, family)
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
return (s);
if (errno != EADDRINUSE) {
(void)_libc_close(s);
(void)_close(s);
return (-1);
}
#endif
*sport = 0;
if (bindresvport_sa(s, (struct sockaddr *)&ss) == -1) {
(void)_libc_close(s);
(void)_close(s);
return (-1);
}
*alport = (int)ntohs(*sport);

View File

@ -428,7 +428,7 @@ res_send(buf, buflen, ans, anssiz)
read_len:
cp = ans;
len = INT16SZ;
while ((n = _libc_read(s, (char *)cp, (int)len)) > 0) {
while ((n = _read(s, (char *)cp, (int)len)) > 0) {
cp += n;
if ((len -= n) <= 0)
break;
@ -476,7 +476,7 @@ res_send(buf, buflen, ans, anssiz)
}
cp = ans;
while (len != 0 &&
(n = _libc_read(s, (char *)cp, (int)len)) > 0) {
(n = _read(s, (char *)cp, (int)len)) > 0) {
cp += n;
len -= n;
}
@ -499,7 +499,7 @@ res_send(buf, buflen, ans, anssiz)
n = (len > sizeof(junk)
? sizeof(junk)
: len);
if ((n = _libc_read(s, junk, n)) > 0)
if ((n = _read(s, junk, n)) > 0)
len -= n;
else
break;
@ -608,7 +608,7 @@ res_send(buf, buflen, ans, anssiz)
if (s1 < 0)
goto bad_dg_sock;
(void)dup2(s1, s);
(void)_libc_close(s1);
(void)_close(s1);
Dprint(_res.options & RES_DEBUG,
(stdout, ";; new DG socket\n"))
#endif /* CAN_RECONNECT */
@ -893,7 +893,7 @@ void
res_close()
{
if (s >= 0) {
(void)_libc_close(s);
(void)_close(s);
s = -1;
connected = 0;
vc = 0;

View File

@ -285,7 +285,7 @@ nl_catd catd;
return -1;
}
if (cat->loadType != MCLoadAll) _libc_close(cat->fd);
if (cat->loadType != MCLoadAll) _close(cat->fd);
for (i = 0; i < cat->numSets; ++i) {
set = cat->sets + i;
if (!set->invalid) {
@ -321,14 +321,14 @@ __const char *catpath;
if (!cat) return(NLERR);
cat->loadType = MCLoadBySet;
if ((cat->fd = _libc_open(catpath, O_RDONLY)) < 0) {
if ((cat->fd = _open(catpath, O_RDONLY)) < 0) {
free(cat);
return(NLERR);
}
(void)_libc_fcntl(cat->fd, F_SETFD, FD_CLOEXEC);
(void)_fcntl(cat->fd, F_SETFD, FD_CLOEXEC);
if (_libc_read(cat->fd, &header, sizeof(header)) != sizeof(header))
if (_read(cat->fd, &header, sizeof(header)) != sizeof(header))
CORRUPT();
if (strncmp(header.magic, MCMagic, MCMagicLen) != 0) CORRUPT();
@ -369,7 +369,7 @@ __const char *catpath;
/* read in the set header */
set = cat->sets + i;
if (_libc_read(cat->fd, set, sizeof(*set)) != sizeof(*set)) {
if (_read(cat->fd, set, sizeof(*set)) != sizeof(*set)) {
for (j = 0; j < i; j++) {
set = cat->sets + j;
if (!set->invalid) {
@ -408,7 +408,7 @@ __const char *catpath;
nextSet = set->nextSet;
}
if (cat->loadType == MCLoadAll) {
_libc_close(cat->fd);
_close(cat->fd);
cat->fd = -1;
}
return((nl_catd) cat);
@ -424,7 +424,7 @@ MCSetT *set;
/* Get the data */
if (lseek(cat->fd, set->data.off, 0) == -1) return(0);
if ((set->data.str = malloc(set->dataLen)) == NULL) return(-1);
if (_libc_read(cat->fd, set->data.str, set->dataLen) != set->dataLen) {
if (_read(cat->fd, set->data.str, set->dataLen) != set->dataLen) {
free(set->data.str); return(0);
}
@ -438,7 +438,7 @@ MCSetT *set;
for (i = 0; i < set->numMsgs; ++i) {
msg = set->u.msgs + i;
if (_libc_read(cat->fd, msg, sizeof(*msg)) != sizeof(*msg)) {
if (_read(cat->fd, msg, sizeof(*msg)) != sizeof(*msg)) {
free(set->u.msgs); free(set->data.str); return(0);
}
if (msg->invalid) {

View File

@ -437,7 +437,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
msg("alarm caught it, must be unreachable.");
goto error;
}
res = _libc_read(s, (char *)&thetime, sizeof(thetime));
res = _read(s, (char *)&thetime, sizeof(thetime));
if (res != sizeof(thetime)) {
if (saw_alarm)
msg("timed out TCP call.");
@ -449,7 +449,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
time_valid = 1;
}
save = errno;
(void)_libc_close(s);
(void)_close(s);
errno = save;
s = RPC_ANYSOCK;
@ -468,7 +468,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid)
*/
if (s != RPC_ANYSOCK)
(void)_libc_close(s);
(void)_close(s);
if (clnt != NULL)
clnt_destroy(clnt);

View File

@ -86,7 +86,7 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
} else {
crp->valid = 0;
if (crp->socket != -1)
(void)_libc_close(crp->socket);
(void)_close(crp->socket);
crp->socket = RPC_ANYSOCK;
if (crp->client) {
clnt_destroy(crp->client);

View File

@ -167,7 +167,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
if (*sockp != -1)
(void)_libc_close(*sockp);
(void)_close(*sockp);
goto fooy;
}
ct->ct_closeit = TRUE;
@ -200,7 +200,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
XDR_ENCODE);
if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
if (ct->ct_closeit) {
(void)_libc_close(*sockp);
(void)_close(*sockp);
}
goto fooy;
}
@ -474,7 +474,7 @@ clnttcp_destroy(h)
(struct ct_data *) h->cl_private;
if (ct->ct_closeit) {
(void)_libc_close(ct->ct_sock);
(void)_close(ct->ct_sock);
}
XDR_DESTROY(&(ct->ct_xdrs));
mem_free((caddr_t)ct, sizeof(struct ct_data));
@ -544,7 +544,7 @@ readtcp(ct, buf, len)
}
break;
}
switch (len = _libc_read(ct->ct_sock, buf, len)) {
switch (len = _read(ct->ct_sock, buf, len)) {
case 0:
/* premature eof */
@ -570,7 +570,7 @@ writetcp(ct, buf, len)
register int i, cnt;
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
if ((i = _libc_write(ct->ct_sock, buf, cnt)) == -1) {
if ((i = _write(ct->ct_sock, buf, cnt)) == -1) {
ct->ct_error.re_errno = errno;
ct->ct_error.re_status = RPC_CANTSEND;
return (-1);

View File

@ -559,7 +559,7 @@ clntudp_destroy(cl)
register struct cu_data *cu = (struct cu_data *)cl->cl_private;
if (cu->cu_closeit) {
(void)_libc_close(cu->cu_sock);
(void)_close(cu->cu_sock);
}
XDR_DESTROY(&(cu->cu_outxdrs));
mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz));

View File

@ -158,7 +158,7 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
if (*sockp != -1)
(void)_libc_close(*sockp);
(void)_close(*sockp);
goto fooy;
}
ct->ct_closeit = TRUE;
@ -191,7 +191,7 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
XDR_ENCODE);
if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) {
if (ct->ct_closeit) {
(void)_libc_close(*sockp);
(void)_close(*sockp);
}
goto fooy;
}
@ -465,7 +465,7 @@ clntunix_destroy(h)
(struct ct_data *) h->cl_private;
if (ct->ct_closeit) {
(void)_libc_close(ct->ct_sock);
(void)_close(ct->ct_sock);
}
XDR_DESTROY(&(ct->ct_xdrs));
mem_free((caddr_t)ct, sizeof(struct ct_data));

View File

@ -73,7 +73,7 @@ get_myaddress(addr)
ifc.ifc_len = sizeof (buf);
ifc.ifc_buf = buf;
if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) {
_libc_close(s);
_close(s);
return(-1);
}
again:
@ -83,7 +83,7 @@ get_myaddress(addr)
while (ifr < end) {
ifreq = *ifr;
if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
_libc_close(s);
_close(s);
return(-1);
}
if (((ifreq.ifr_flags & IFF_UP) &&
@ -107,6 +107,6 @@ get_myaddress(addr)
loopback = 1;
goto again;
}
(void)_libc_close(s);
(void)_close(s);
return (gotit ? 0 : -1);
}

View File

@ -369,7 +369,7 @@ int vers;
(void) clnt_control(kcp->client, CLSET_RETRY_TIMEOUT,
(char *)&wait_time);
if (clnt_control(kcp->client, CLGET_FD, (char *)&fd))
_libc_fcntl(fd, F_SETFD, 1); /* make it "close on exec" */
_fcntl(fd, F_SETFD, 1); /* make it "close on exec" */
return (kcp->client);
}

View File

@ -102,7 +102,7 @@ pmap_set(program, version, protocol, port)
}
CLNT_DESTROY(client);
if (socket != -1)
(void)_libc_close(socket);
(void)_close(socket);
return (rslt);
}
@ -144,6 +144,6 @@ pmap_unset(program, version)
tottimeout);
CLNT_DESTROY(client);
if (socket != -1)
(void)_libc_close(socket);
(void)_close(socket);
return (rslt);
}

View File

@ -80,7 +80,7 @@ pmap_getmaps(address)
CLNT_DESTROY(client);
}
if (socket != -1)
(void)_libc_close(socket);
(void)_close(socket);
address->sin_port = 0;
return (head);
}

View File

@ -85,7 +85,7 @@ pmap_getport(address, program, version, protocol)
CLNT_DESTROY(client);
}
if (socket != -1)
(void)_libc_close(socket);
(void)_close(socket);
address->sin_port = 0;
return (port);
}

View File

@ -98,7 +98,7 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt
stat = RPC_FAILED;
}
if (socket != -1)
(void)_libc_close(socket);
(void)_close(socket);
addr->sin_port = 0;
return (stat);
}
@ -408,7 +408,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
if (fds != &readfds)
free(fds);
if (sock >= 0)
(void)_libc_close(sock);
(void)_close(sock);
AUTH_DESTROY(unix_auth);
return (stat);
}

View File

@ -129,7 +129,7 @@ rtime(addrp, timep, timeout)
do_close(s);
return(-1);
}
res = _libc_read(s, (char *)&thetime, sizeof(thetime));
res = _read(s, (char *)&thetime, sizeof(thetime));
do_close(s);
if (res < 0) {
return(-1);
@ -152,6 +152,6 @@ do_close(s)
int save;
save = errno;
(void)_libc_close(s);
(void)_close(s);
errno = save;
}

View File

@ -145,7 +145,7 @@ svctcp_create(sock, sendsize, recvsize)
if (ioctl(sock, FIONBIO, &on) < 0) {
perror("svc_tcp.c - cannot turn on non-blocking mode");
if (madesock)
(void)_libc_close(sock);
(void)_close(sock);
return ((SVCXPRT *)NULL);
}
memset(&addr, 0, sizeof (addr));
@ -159,7 +159,7 @@ svctcp_create(sock, sendsize, recvsize)
(listen(sock, 2) != 0)) {
perror("svctcp_.c - cannot getsockname or listen");
if (madesock)
(void)_libc_close(sock);
(void)_close(sock);
return ((SVCXPRT *)NULL);
}
r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r));
@ -257,7 +257,7 @@ rendezvous_request(xprt)
* Guard against FTP bounce attacks.
*/
if (addr.sin_port == htons(20)) {
_libc_close(sock);
_close(sock);
return (FALSE);
}
/*
@ -265,7 +265,7 @@ rendezvous_request(xprt)
*/
off = 0;
if (ioctl(sock, FIONBIO, &off) < 0) {
_libc_close(sock);
_close(sock);
return (FALSE);
}
/*
@ -291,7 +291,7 @@ svctcp_destroy(xprt)
register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1;
xprt_unregister(xprt);
(void)_libc_close(xprt->xp_sock);
(void)_close(xprt->xp_sock);
if (xprt->xp_port != 0) {
/* a rendezvouser socket */
xprt->xp_port = 0;
@ -376,7 +376,7 @@ readtcp(xprt, buf, len)
}
}
} while (!FD_ISSET(sock, fds));
if ((len = _libc_read(sock, buf, len)) > 0) {
if ((len = _read(sock, buf, len)) > 0) {
if (fds != NULL)
free(fds);
return (len);
@ -401,7 +401,7 @@ writetcp(xprt, buf, len)
register int i, cnt;
for (cnt = len; cnt > 0; cnt -= i, buf += i) {
if ((i = _libc_write(xprt->xp_sock, buf, cnt)) < 0) {
if ((i = _write(xprt->xp_sock, buf, cnt)) < 0) {
((struct tcp_conn *)(xprt->xp_p1))->strm_stat =
XPRT_DIED;
return (-1);

View File

@ -123,7 +123,7 @@ svcudp_bufcreate(sock, sendsz, recvsz)
if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) {
perror("svcudp_create - cannot getsockname");
if (madesock)
(void)_libc_close(sock);
(void)_close(sock);
return ((SVCXPRT *)NULL);
}
xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT));
@ -259,7 +259,7 @@ svcudp_destroy(xprt)
register struct svcudp_data *su = su_data(xprt);
xprt_unregister(xprt);
(void)_libc_close(xprt->xp_sock);
(void)_close(xprt->xp_sock);
XDR_DESTROY(&(su->su_xdrs));
mem_free(rpc_buffer(xprt), su->su_iosz);
mem_free((caddr_t)su, sizeof(struct svcudp_data));

View File

@ -213,7 +213,7 @@ svcunix_create(sock, sendsize, recvsize, path)
(listen(sock, 2) != 0)) {
perror("svc_unix.c - cannot getsockname or listen");
if (madesock)
(void)_libc_close(sock);
(void)_close(sock);
return ((SVCXPRT *)NULL);
}
r = (struct unix_rendezvous *)mem_alloc(sizeof(*r));
@ -333,7 +333,7 @@ svcunix_destroy(xprt)
register struct unix_conn *cd = (struct unix_conn *)xprt->xp_p1;
xprt_unregister(xprt);
(void)_libc_close(xprt->xp_sock);
(void)_close(xprt->xp_sock);
if (xprt->xp_port != 0) {
/* a rendezvouser socket */
xprt->xp_port = 0;

View File

@ -63,7 +63,7 @@ fdopen(fd, mode)
return (NULL);
/* Make sure the mode the user wants is a subset of the actual mode. */
if ((fdflags = _libc_fcntl(fd, F_GETFL, 0)) < 0)
if ((fdflags = _fcntl(fd, F_GETFL, 0)) < 0)
return (NULL);
tmp = fdflags & O_ACCMODE;
if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) {

View File

@ -60,7 +60,7 @@ fopen(file, mode)
return (NULL);
if ((fp = __sfp()) == NULL)
return (NULL);
if ((f = _libc_open(file, oflags, DEFFILEMODE)) < 0) {
if ((f = _open(file, oflags, DEFFILEMODE)) < 0) {
fp->_flags = 0; /* release */
return (NULL);
}

View File

@ -100,13 +100,13 @@ freopen(file, mode, fp)
}
/* Get a new descriptor to refer to the new file. */
f = _libc_open(file, oflags, DEFFILEMODE);
f = _open(file, oflags, DEFFILEMODE);
if (f < 0 && isopen) {
/* If out of fd's close the old one and try again. */
if (errno == ENFILE || errno == EMFILE) {
(void) (*fp->_close)(fp->_cookie);
isopen = 0;
f = _libc_open(file, oflags, DEFFILEMODE);
f = _open(file, oflags, DEFFILEMODE);
}
}
sverrno = errno;
@ -147,7 +147,7 @@ freopen(file, mode, fp)
*/
if (wantfd >= 0 && f != wantfd) {
if (dup2(f, wantfd) >= 0) {
(void)_libc_close(f);
(void)_close(f);
f = wantfd;
}
}

View File

@ -59,7 +59,7 @@ gets(buf)
"warning: this program uses gets(), which is unsafe.\n";
if (!warned) {
(void) _libc_write(STDERR_FILENO, w, sizeof(w) - 1);
(void) _write(STDERR_FILENO, w, sizeof(w) - 1);
warned = 1;
}
for (s = buf; (c = getchar()) != '\n';)

View File

@ -163,7 +163,7 @@ _gettemp(path, doopen, domkdir, slen)
for (;;) {
if (doopen) {
if ((*doopen =
_libc_open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
_open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
return(1);
if (errno != EEXIST)
return(0);

View File

@ -60,7 +60,7 @@ __sread(cookie, buf, n)
register FILE *fp = cookie;
register int ret;
ret = _libc_read(fp->_file, buf, (size_t)n);
ret = _read(fp->_file, buf, (size_t)n);
/* if the read succeeded, update the current offset */
if (ret >= 0)
fp->_offset += ret;
@ -80,7 +80,7 @@ __swrite(cookie, buf, n)
if (fp->_flags & __SAPP)
(void) lseek(fp->_file, (off_t)0, SEEK_END);
fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */
return (_libc_write(fp->_file, buf, (size_t)n));
return (_write(fp->_file, buf, (size_t)n));
}
fpos_t
@ -107,5 +107,5 @@ __sclose(cookie)
void *cookie;
{
return (_libc_close(((FILE *)cookie)->_file));
return (_close(((FILE *)cookie)->_file));
}

View File

@ -74,7 +74,7 @@ tmpfile()
if ((fp = fdopen(fd, "w+")) == NULL) {
sverrno = errno;
(void)_libc_close(fd);
(void)_close(fd);
errno = sverrno;
return (NULL);
}

View File

@ -72,7 +72,7 @@
static int fdzero;
# define MMAP_FD fdzero
# define INIT_MMAP() \
{ if ((fdzero = _libc_open("/dev/zero", O_RDWR, 0000)) == -1) \
{ if ((fdzero = _open("/dev/zero", O_RDWR, 0000)) == -1) \
wrterror("open of /dev/zero"); }
# define MADV_FREE MADV_DONTNEED
#endif /* __sparc__ */
@ -275,10 +275,10 @@ static void
wrterror(char *p)
{
char *q = " error: ";
_libc_write(STDERR_FILENO, __progname, strlen(__progname));
_libc_write(STDERR_FILENO, malloc_func, strlen(malloc_func));
_libc_write(STDERR_FILENO, q, strlen(q));
_libc_write(STDERR_FILENO, p, strlen(p));
_write(STDERR_FILENO, __progname, strlen(__progname));
_write(STDERR_FILENO, malloc_func, strlen(malloc_func));
_write(STDERR_FILENO, q, strlen(q));
_write(STDERR_FILENO, p, strlen(p));
suicide = 1;
abort();
}
@ -289,10 +289,10 @@ wrtwarning(char *p)
char *q = " warning: ";
if (malloc_abort)
wrterror(p);
_libc_write(STDERR_FILENO, __progname, strlen(__progname));
_libc_write(STDERR_FILENO, malloc_func, strlen(malloc_func));
_libc_write(STDERR_FILENO, q, strlen(q));
_libc_write(STDERR_FILENO, p, strlen(p));
_write(STDERR_FILENO, __progname, strlen(__progname));
_write(STDERR_FILENO, malloc_func, strlen(malloc_func));
_write(STDERR_FILENO, q, strlen(q));
_write(STDERR_FILENO, p, strlen(p));
}
/*

View File

@ -298,11 +298,11 @@ srandomdev()
len = rand_deg * sizeof state[0];
done = 0;
fd = _libc_open("/dev/urandom", O_RDONLY, 0);
fd = _open("/dev/urandom", O_RDONLY, 0);
if (fd >= 0) {
if (_libc_read(fd, (void *) state, len) == (ssize_t) len)
if (_read(fd, (void *) state, len) == (ssize_t) len)
done = 1;
_libc_close(fd);
_close(fd);
}
if (!done) {

View File

@ -67,7 +67,7 @@ realpath(path, resolved)
int symlinks = 0;
/* Save the starting point. */
if ((fd = _libc_open(".", O_RDONLY)) < 0) {
if ((fd = _open(".", O_RDONLY)) < 0) {
(void)strcpy(resolved, ".");
return (NULL);
}
@ -154,12 +154,12 @@ realpath(path, resolved)
}
/* It's okay if the close fails, what's an fd more or less? */
(void)_libc_close(fd);
(void)_close(fd);
return (resolved);
err1: serrno = errno;
(void)fchdir(fd);
err2: (void)_libc_close(fd);
err2: (void)_close(fd);
errno = serrno;
return (NULL);
}

View File

@ -84,7 +84,7 @@ __system(command)
_exit(127);
default: /* parent */
do {
pid = _libc_waitpid(pid, &pstat, 0);
pid = _wait4(pid, &pstat, 0, (struct rusage *)0);
} while (pid == -1 && errno == EINTR);
break;
}
@ -94,5 +94,4 @@ __system(command)
return(pid == -1 ? -1 : pstat);
}
__weak_reference(__system, _libc_system);
__weak_reference(_libc_system, system);
__weak_reference(__system, system);

View File

@ -314,7 +314,7 @@ register struct state * const sp;
}
if (doaccess && access(name, R_OK) != 0)
return -1;
if ((fid = _libc_open(name, OPEN_MODE)) == -1)
if ((fid = _open(name, OPEN_MODE)) == -1)
return -1;
if ((fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode))
return -1;
@ -325,8 +325,8 @@ register struct state * const sp;
int ttisstdcnt;
int ttisgmtcnt;
i = _libc_read(fid, buf, sizeof buf);
if (_libc_close(fid) != 0)
i = _read(fid, buf, sizeof buf);
if (_close(fid) != 0)
return -1;
p = buf;
p += (sizeof tzhp->tzh_magic) + (sizeof tzhp->tzh_reserved);

View File

@ -157,7 +157,7 @@ __time_load_locale(const char *name)
strcat(filename, "/");
strcat(filename, name);
strcat(filename, "/LC_TIME");
fd = _libc_open(filename, O_RDONLY);
fd = _open(filename, O_RDONLY);
if (fd < 0)
goto no_locale;
if (fstat(fd, &st) != 0)
@ -173,9 +173,9 @@ __time_load_locale(const char *name)
(void) strcpy(lbuf, name);
p = lbuf + namesize;
plim = p + st.st_size;
if (_libc_read(fd, p, (size_t) st.st_size) != st.st_size)
if (_read(fd, p, (size_t) st.st_size) != st.st_size)
goto bad_lbuf;
if (_libc_close(fd) != 0)
if (_close(fd) != 0)
goto bad_lbuf;
/*
** Parse the locale file into localebuf.
@ -211,7 +211,7 @@ __time_load_locale(const char *name)
bad_lbuf:
free(lbuf);
bad_locale:
(void)_libc_close(fd);
(void)_close(fd);
no_locale:
_time_using_locale = save_using_locale;
return -1;

View File

@ -350,7 +350,7 @@ _yp_dobind(dom, ypdb)
ysd->dom_vers = 0;
ysd->dom_client = NULL;
sock = dup2(save, sock);
_libc_close(save);
_close(save);
}
}
@ -373,10 +373,10 @@ _yp_dobind(dom, ypdb)
ysd->dom_socket = -1;
}
snprintf(path, sizeof(path), "%s/%s.%d", BINDINGDIR, dom, 2);
if((fd = _libc_open(path, O_RDONLY)) == -1) {
if((fd = _open(path, O_RDONLY)) == -1) {
/* no binding file, YP is dead. */
/* Try to bring it back to life. */
_libc_close(fd);
_close(fd);
goto skipit;
}
if( flock(fd, LOCK_EX|LOCK_NB) == -1 && errno==EWOULDBLOCK) {
@ -391,7 +391,7 @@ _yp_dobind(dom, ypdb)
r = readv(fd, iov, 2);
if(r != iov[0].iov_len + iov[1].iov_len) {
_libc_close(fd);
_close(fd);
ysd->dom_vers = -1;
goto again;
}
@ -405,12 +405,12 @@ _yp_dobind(dom, ypdb)
*(u_short *)&ybr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port;
ysd->dom_server_port = ysd->dom_server_addr.sin_port;
_libc_close(fd);
_close(fd);
goto gotit;
} else {
/* no lock on binding file, YP is dead. */
/* Try to bring it back to life. */
_libc_close(fd);
_close(fd);
goto skipit;
}
}
@ -478,9 +478,15 @@ _yp_dobind(dom, ypdb)
goto again;
} else {
if (ypbr.ypbind_status != YPBIND_SUCC_VAL) {
struct timespec time_to_sleep, time_remaining;
clnt_destroy(client);
ysd->dom_vers = -1;
_libc_sleep(_yplib_timeout/2);
time_to_sleep.tv_sec = _yplib_timeout/2;
time_to_sleep.tv_nsec = 0;
_nanosleep(&time_to_sleep,
&time_remaining);
goto again;
}
}
@ -518,7 +524,7 @@ _yp_dobind(dom, ypdb)
ysd->dom_vers = -1;
goto again;
}
if(_libc_fcntl(ysd->dom_socket, F_SETFD, 1) == -1)
if(_fcntl(ysd->dom_socket, F_SETFD, 1) == -1)
perror("fcntl: F_SETFD");
/*
* We want a port number associated with this socket
@ -567,7 +573,7 @@ _yp_unbind(ypb)
save = dup(ypb->dom_socket);
clnt_destroy(ypb->dom_client);
sock = dup2(save, sock);
_libc_close(save);
_close(save);
} else
clnt_destroy(ypb->dom_client);
}

View File

@ -26,7 +26,7 @@ PRECIOUSLIB= yes
# This is a list of syscalls that are renamed as _thread_sys_{syscall}
# so that libc_r can provide replacement functions.
#
HIDDEN_SYSCALLS= accept.o bind.o close.o connect.o dup.o dup2.o \
HIDDEN_SYSCALLS= aio_suspend.o accept.o bind.o close.o connect.o dup.o dup2.o \
execve.o fchflags.o fchmod.o fchown.o fcntl.o \
flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \
getlogin.o getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \

View File

@ -5,6 +5,7 @@
SRCS+= \
uthread_accept.c \
uthread_aio_suspend.c \
uthread_attr_destroy.c \
uthread_attr_init.c \
uthread_attr_getdetachstate.c \
@ -31,6 +32,7 @@ SRCS+= \
uthread_condattr_destroy.c \
uthread_condattr_init.c \
uthread_connect.c \
uthread_creat.c \
uthread_create.c \
uthread_detach.c \
uthread_dup.c \
@ -76,6 +78,7 @@ SRCS+= \
uthread_nanosleep.c \
uthread_once.c \
uthread_open.c \
uthread_pause.c \
uthread_pipe.c \
uthread_poll.c \
uthread_priority_queue.c \
@ -106,14 +109,19 @@ SRCS+= \
uthread_sigsuspend.c \
uthread_sigwait.c \
uthread_single_np.c \
uthread_sleep.c \
uthread_socket.c \
uthread_socketpair.c \
uthread_spec.c \
uthread_spinlock.c \
uthread_suspend_np.c \
uthread_switch_np.c \
uthread_system.c \
uthread_tcdrain.c \
uthread_vfork.c \
uthread_wait.c \
uthread_wait4.c \
uthread_waitpid.c \
uthread_write.c \
uthread_writev.c \
uthread_yield.c

View File

@ -41,7 +41,7 @@
#include "pthread_private.h"
int
_libc_accept(int fd, struct sockaddr * name, socklen_t *namelen)
_accept(int fd, struct sockaddr * name, socklen_t *namelen)
{
int ret;
@ -107,5 +107,5 @@ _libc_accept(int fd, struct sockaddr * name, socklen_t *namelen)
return (ret);
}
__weak_reference(_libc_accept, accept);
__weak_reference(_accept, accept);
#endif

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice(s), this list of conditions and the following disclaimer as
* the first lines of this file unmodified other than the possible
* addition of one or more copyright notices.
* 2. Redistributions in binary form must reproduce the above copyright
* notice(s), this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT 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$
*/
#include <aio.h>
#ifdef _THREAD_SAFE
#include <pthread.h>
#include "pthread_private.h"
int
_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
timespec *timeout)
{
int ret;
_thread_enter_cancellation_point();
ret = _aio_suspend(iocbs, niocb, timeout);
_thread_leave_cancellation_point();
return ret;
}
__weak_reference(_aio_suspend, aio_suspend);
#endif

View File

@ -38,7 +38,7 @@
#include "pthread_private.h"
int
_libc_bind(int fd, const struct sockaddr * name, socklen_t namelen)
_bind(int fd, const struct sockaddr * name, socklen_t namelen)
{
int ret;
@ -49,5 +49,5 @@ _libc_bind(int fd, const struct sockaddr * name, socklen_t namelen)
return (ret);
}
__weak_reference(_libc_bind, bind);
__weak_reference(_bind, bind);
#endif

View File

@ -41,15 +41,13 @@
#include "pthread_private.h"
int
_libc_close(int fd)
_close(int fd)
{
int flags;
int ret;
struct stat sb;
struct fd_table_entry *entry;
_thread_enter_cancellation_point();
if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) {
/*
* Don't allow silly programs to close the kernel pipe.
@ -99,9 +97,18 @@ _libc_close(int fd)
/* Close the file descriptor: */
ret = _thread_sys_close(fd);
}
_thread_leave_cancellation_point();
return (ret);
}
__weak_reference(_libc_close, close);
int
close(int fd)
{
int ret;
_thread_enter_cancellation_point();
ret = _close(fd);
_thread_leave_cancellation_point();
return ret;
}
#endif

View File

@ -160,6 +160,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
int rval = 0;
int interrupted = 0;
_thread_enter_cancellation_point();
if (cond == NULL)
rval = EINVAL;
@ -286,6 +288,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
_thread_leave_cancellation_point();
}
_thread_leave_cancellation_point();
/* Return the completion status: */
return (rval);
}
@ -297,12 +301,15 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
int rval = 0;
int interrupted = 0;
_thread_enter_cancellation_point();
if (cond == NULL || abstime == NULL)
rval = EINVAL;
if (abstime->tv_sec < 0 ||
abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
errno = EINVAL;
_thread_leave_cancellation_point();
return (-1);
}
@ -448,6 +455,8 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
_thread_leave_cancellation_point();
}
_thread_leave_cancellation_point();
/* Return the completion status: */
return (rval);
}

View File

@ -40,7 +40,7 @@
#include "pthread_private.h"
int
_libc_connect(int fd, const struct sockaddr * name, socklen_t namelen)
_connect(int fd, const struct sockaddr * name, socklen_t namelen)
{
struct sockaddr tmpname;
int errnolen, ret, tmpnamelen;
@ -76,5 +76,5 @@ _libc_connect(int fd, const struct sockaddr * name, socklen_t namelen)
return (ret);
}
__weak_reference(_libc_connect, connect);
__weak_reference(_connect, connect);
#endif

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice(s), this list of conditions and the following disclaimer as
* the first lines of this file unmodified other than the possible
* addition of one or more copyright notices.
* 2. Redistributions in binary form must reproduce the above copyright
* notice(s), this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT 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$
*/
#include <fcntl.h>
#ifdef _THREAD_SAFE
#include <pthread.h>
#include "pthread_private.h"
int
creat(const char *path, mode_t mode)
{
int ret;
_thread_enter_cancellation_point();
ret = __creat(path, mode);
_thread_leave_cancellation_point();
return ret;
}
#endif

View File

@ -37,7 +37,7 @@
#include "pthread_private.h"
int
_libc_dup(int fd)
_dup(int fd)
{
int ret;
@ -68,5 +68,5 @@ _libc_dup(int fd)
return (ret);
}
__weak_reference(_libc_dup, dup);
__weak_reference(_dup, dup);
#endif

View File

@ -38,7 +38,7 @@
#include "pthread_private.h"
int
_libc_dup2(int fd, int newfd)
_dup2(int fd, int newfd)
{
int ret;
int newfd_opened;
@ -84,5 +84,5 @@ _libc_dup2(int fd, int newfd)
return (ret);
}
__weak_reference(_libc_dup2, dup2);
__weak_reference(_dup2, dup2);
#endif

View File

@ -39,7 +39,7 @@
#include "pthread_private.h"
int
_libc_execve(const char *name, char *const * argv, char *const * envp)
_execve(const char *name, char *const * argv, char *const * envp)
{
int flags;
int i;
@ -111,5 +111,5 @@ _libc_execve(const char *name, char *const * argv, char *const * envp)
return (ret);
}
__weak_reference(_libc_execve, execve);
__weak_reference(_execve, execve);
#endif

View File

@ -41,7 +41,7 @@
#include <pthread.h>
#include "pthread_private.h"
void _libc__exit(int status)
void __exit(int status)
{
int flags;
int i;
@ -77,7 +77,7 @@ void _libc__exit(int status)
_thread_sys__exit(status);
}
__weak_reference(_libc__exit, _exit);
__weak_reference(__exit, _exit);
void
_thread_exit(char *fname, int lineno, char *string)

View File

@ -12,7 +12,7 @@
#include "pthread_private.h"
int
_libc_fchflags(int fd, u_long flags)
_fchflags(int fd, u_long flags)
{
int ret;
@ -23,5 +23,5 @@ _libc_fchflags(int fd, u_long flags)
return (ret);
}
__weak_reference(_libc_fchflags, fchflags);
__weak_reference(_fchflags, fchflags);
#endif

View File

@ -38,7 +38,7 @@
#include "pthread_private.h"
int
_libc_fchmod(int fd, mode_t mode)
_fchmod(int fd, mode_t mode)
{
int ret;
@ -49,5 +49,5 @@ _libc_fchmod(int fd, mode_t mode)
return (ret);
}
__weak_reference(_libc_fchmod, fchmod);
__weak_reference(_fchmod, fchmod);
#endif

View File

@ -39,7 +39,7 @@
#include "pthread_private.h"
int
_libc_fchown(int fd, uid_t owner, gid_t group)
_fchown(int fd, uid_t owner, gid_t group)
{
int ret;
@ -50,5 +50,5 @@ _libc_fchown(int fd, uid_t owner, gid_t group)
return (ret);
}
__weak_reference(_libc_fchown, fchown);
__weak_reference(_fchown, fchown);
#endif

View File

@ -39,7 +39,7 @@
#include "pthread_private.h"
int
_libc_fcntl(int fd, int cmd,...)
_fcntl(int fd, int cmd,...)
{
int flags = 0;
int nonblock;
@ -47,8 +47,6 @@ _libc_fcntl(int fd, int cmd,...)
int ret;
va_list ap;
_thread_enter_cancellation_point();
/* Lock the file descriptor: */
if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
/* Initialise the variable argument list: */
@ -137,11 +135,36 @@ _libc_fcntl(int fd, int cmd,...)
/* Unlock the file descriptor: */
_FD_UNLOCK(fd, FD_RDWR);
}
_thread_leave_cancellation_point();
/* Return the completion status: */
return (ret);
}
__weak_reference(_libc_fcntl, fcntl);
int
fcntl(int fd, int cmd,...)
{
int ret;
va_list ap;
_thread_enter_cancellation_point();
va_start(ap, cmd);
switch (cmd) {
case F_DUPFD:
case F_SETFD:
case F_SETFL:
ret = fcntl(fd, cmd, va_arg(ap, int));
break;
case F_GETFD:
case F_GETFL:
ret = fcntl(fd, cmd);
break;
default:
ret = fcntl(fd, cmd, va_arg(ap, void *));
}
va_end(ap);
_thread_leave_cancellation_point();
return ret;
}
#endif

View File

@ -37,7 +37,7 @@
#include "pthread_private.h"
int
_libc_flock(int fd, int operation)
_flock(int fd, int operation)
{
int ret;
@ -48,5 +48,5 @@ _libc_flock(int fd, int operation)
return (ret);
}
__weak_reference(_libc_flock, flock);
__weak_reference(_flock, flock);
#endif

View File

@ -41,7 +41,7 @@
#include "pthread_private.h"
pid_t
_libc_fork(void)
_fork(void)
{
int i, flags;
pid_t ret;
@ -221,5 +221,5 @@ _libc_fork(void)
return (ret);
}
__weak_reference(_libc_fork, fork);
__weak_reference(_fork, fork);
#endif

View File

@ -42,7 +42,7 @@
#include "pthread_private.h"
int
_libc_fstat(int fd, struct stat * buf)
_fstat(int fd, struct stat * buf)
{
int ret;
@ -56,5 +56,5 @@ _libc_fstat(int fd, struct stat * buf)
return (ret);
}
__weak_reference(_libc_fstat, fstat);
__weak_reference(_fstat, fstat);
#endif

View File

@ -42,7 +42,7 @@
#include "pthread_private.h"
int
_libc_fstatfs(int fd, struct statfs * buf)
_fstatfs(int fd, struct statfs * buf)
{
int ret;
@ -56,5 +56,5 @@ _libc_fstatfs(int fd, struct statfs * buf)
return (ret);
}
__weak_reference(_libc_fstatfs, fstatfs);
__weak_reference(_fstatfs, fstatfs);
#endif

View File

@ -37,18 +37,26 @@
#include "pthread_private.h"
int
_libc_fsync(int fd)
_fsync(int fd)
{
int ret;
int ret;
_thread_enter_cancellation_point();
if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
ret = _thread_sys_fsync(fd);
_FD_UNLOCK(fd, FD_RDWR);
}
_thread_leave_cancellation_point();
return (ret);
}
__weak_reference(_libc_fsync, fsync);
int
fsync(int fd)
{
int ret;
_thread_enter_cancellation_point();
ret = _fsync(fd);
_thread_leave_cancellation_point();
return ret;
}
#endif

View File

@ -38,7 +38,7 @@
#include "pthread_private.h"
int
_libc_getdirentries(int fd, char *buf, int nbytes, long *basep)
_getdirentries(int fd, char *buf, int nbytes, long *basep)
{
int ret;
@ -49,5 +49,5 @@ _libc_getdirentries(int fd, char *buf, int nbytes, long *basep)
return (ret);
}
__weak_reference(_libc_getdirentries, getdirentries);
__weak_reference(_getdirentries, getdirentries);
#endif

View File

@ -38,7 +38,7 @@
#include "pthread_private.h"
int
_libc_getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen)
_getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen)
{
int ret;
@ -49,5 +49,5 @@ _libc_getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen)
return ret;
}
__weak_reference(_libc_getpeername, getpeername);
__weak_reference(_getpeername, getpeername);
#endif

View File

@ -38,7 +38,7 @@
#include "pthread_private.h"
int
_libc_getsockname(int s, struct sockaddr * name, socklen_t *namelen)
_getsockname(int s, struct sockaddr * name, socklen_t *namelen)
{
int ret;
@ -49,5 +49,5 @@ _libc_getsockname(int s, struct sockaddr * name, socklen_t *namelen)
return ret;
}
__weak_reference(_libc_getsockname, getsockname);
__weak_reference(_getsockname, getsockname);
#endif

View File

@ -38,7 +38,7 @@
#include "pthread_private.h"
int
_libc_getsockopt(int fd, int level, int optname, void *optval, socklen_t
_getsockopt(int fd, int level, int optname, void *optval, socklen_t
*optlen)
{
int ret;
@ -50,5 +50,5 @@ _libc_getsockopt(int fd, int level, int optname, void *optval, socklen_t
return ret;
}
__weak_reference(_libc_getsockopt, getsockopt);
__weak_reference(_getsockopt, getsockopt);
#endif

View File

@ -39,7 +39,7 @@
#include "pthread_private.h"
int
_libc_ioctl(int fd, unsigned long request,...)
_ioctl(int fd, unsigned long request,...)
{
int ret;
int *op;
@ -77,5 +77,5 @@ _libc_ioctl(int fd, unsigned long request,...)
return (ret);
}
__weak_reference(_libc_ioctl, ioctl);
__weak_reference(_ioctl, ioctl);
#endif

View File

@ -38,7 +38,7 @@
#include "pthread_private.h"
int
_libc_listen(int fd, int backlog)
_listen(int fd, int backlog)
{
int ret;
@ -49,5 +49,5 @@ _libc_listen(int fd, int backlog)
return (ret);
}
__weak_reference(_libc_listen, listen);
__weak_reference(_listen, listen);
#endif

View File

@ -13,30 +13,30 @@
#include "pthread_private.h"
int
_libc_msync(addr, len, flags)
void *addr;
size_t len;
int flags;
_msync(void *addr, size_t len, int flags)
{
int ret;
ret = _thread_sys_msync(addr, len, flags);
return (ret);
}
int
msync(void *addr, size_t len, int flags)
{
int ret;
/*
* XXX This is quite pointless unless we know how to get the
* file descriptor associated with the memory, and lock it for
* write. The only real use of this wrapper is to guarantee
* a cancellation point, as per the standard. sigh.
*/
/* This is a cancellation point: */
_thread_enter_cancellation_point();
ret = _thread_sys_msync(addr, len, flags);
/* No longer in a cancellation point: */
ret = _msync(addr, len, flags);
_thread_leave_cancellation_point();
return (ret);
return ret;
}
__weak_reference(_libc_msync, msync);
#endif

View File

@ -38,7 +38,7 @@
#include "pthread_private.h"
int
_libc_nanosleep(const struct timespec * time_to_sleep,
_nanosleep(const struct timespec * time_to_sleep,
struct timespec * time_remaining)
{
int ret = 0;
@ -47,7 +47,6 @@ _libc_nanosleep(const struct timespec * time_to_sleep,
struct timespec remaining_time;
struct timeval tv;
_thread_enter_cancellation_point();
/* Check if the time to sleep is legal: */
if (time_to_sleep == NULL || time_to_sleep->tv_sec < 0 ||
time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec >= 1000000000) {
@ -117,9 +116,19 @@ _libc_nanosleep(const struct timespec * time_to_sleep,
ret = -1;
}
}
_thread_leave_cancellation_point();
return (ret);
}
__weak_reference(_libc_nanosleep, nanosleep);
int
nanosleep(const struct timespec * time_to_sleep, struct timespec *
time_remaining)
{
int ret;
_thread_enter_cancellation_point();
ret = _nanosleep(time_to_sleep, time_remaining);
_thread_leave_cancellation_point();
return ret;
}
#endif

Some files were not shown because too many files have changed in this diff Show More