include/unistd.h: merged

Also removing lseek64, pread64, pwrite64.

Those functions have lost their "raison d'être", when off_t switched to
64bits.

Change-Id: I5aea35f01d6d10e3d6578a70323da7be5eca315a
This commit is contained in:
Lionel Sambuc 2013-12-02 20:03:35 +01:00
parent 3160cdd5b1
commit d3b0a89bab
18 changed files with 18 additions and 143 deletions

View file

@ -1397,7 +1397,7 @@ ssize_t boot_readwrite(int rw)
{
int r = 0;
if (lseek64(device, (u64_t) offset * SECTOR_SIZE, SEEK_SET, NULL) < 0)
if (lseek(device, offset * SECTOR_SIZE, SEEK_SET) < 0)
return -1;
switch (rw) {

View file

@ -412,9 +412,9 @@ int dir;
#if 0
printf("%s at block %5d\n", dir == READING ? "reading " : "writing", bno);
#endif
r= lseek64(dev, btoa64(bno), SEEK_SET, NULL);
if (r != 0)
fatal("lseek64 failed");
r= lseek(dev, btoa64(bno), SEEK_SET);
if (r < 0)
fatal("lseek failed");
if (dir == READING) {
if (read(dev, rwbuf, block_size) == block_size)
return;

View file

@ -1578,7 +1578,7 @@ ssize_t boot_readwrite(int rw)
{
int r = 0;
if (lseek64(device, (u64_t) offset * SECTOR_SIZE, SEEK_SET, NULL) < 0)
if (lseek(device, offset * SECTOR_SIZE, SEEK_SET) < 0)
return -1;
switch (rw) {

View file

@ -5,6 +5,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <minix/type.h>
#include "tdist.h"

View file

@ -256,7 +256,7 @@ vnd_transfer(devminor_t minor, int do_write, u64_t position,
/* For reads, read in the data for the chunk; possibly less. */
if (!do_write) {
chunk = r = pread64(state.fd, state.buf, chunk,
chunk = r = pread(state.fd, state.buf, chunk,
position);
if (r < 0) {
@ -276,7 +276,7 @@ vnd_transfer(devminor_t minor, int do_write, u64_t position,
/* For writes, write the data to the file; possibly less. */
if (do_write) {
chunk = r = pwrite64(state.fd, state.buf, chunk,
chunk = r = pwrite(state.fd, state.buf, chunk,
position);
if (r <= 0) {

View file

@ -36,7 +36,4 @@ void _loadname(const char *_name, message *_msgptr);
int _len(const char *_s);
void _begsig(int _dummy);
ssize_t pread64(int fd, void *buf, size_t count, u64_t where);
ssize_t pwrite64(int fd, const void *buf, size_t count, u64_t where);
#endif /* _LIB_H */

View file

@ -88,7 +88,7 @@ __dead void _exit(int);
int access(const char *, int);
unsigned int alarm(unsigned int);
int chdir(const char *);
#if !defined(__minix) && (defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE))
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
int chown(const char *, uid_t, gid_t) __RENAME(__posix_chown);
#else
int chown(const char *, uid_t, gid_t);
@ -194,7 +194,7 @@ int ftruncate(int, off_t);
*/
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
defined(_NETBSD_SOURCE)
#ifndef __minix
#ifndef __minix
int fdatasync(int);
#endif /* !__minix */
int fsync(int);
@ -247,7 +247,7 @@ typedef __intptr_t intptr_t;
int brk(void *);
int fchdir(int);
#if !defined(__minix) && defined(_XOPEN_SOURCE)
#if defined(_XOPEN_SOURCE)
int fchown(int, uid_t, gid_t) __RENAME(__posix_fchown);
#else
int fchown(int, uid_t, gid_t);
@ -321,14 +321,6 @@ int unlinkat(int, const char *, int);
/*
* Implementation-defined extensions
*/
#ifdef __minix
int lseek64(int fd, u64_t _offset, int _whence, u64_t *_newpos);
#if defined(_NETBSD_SOURCE)
#include <minix/type.h>
#endif /* defined(_NETBSD_SOURCE) */
#endif /* __minix */
#if defined(_NETBSD_SOURCE)
#ifndef __minix
int acct(const char *);

View file

@ -864,7 +864,6 @@
#define bind _bind
#define chdir _chdir
#define chmod _chmod
#define chown _chown
#define chroot _chroot
#define close _close
#define dup _dup
@ -872,7 +871,6 @@
#define execve _execve
#define fchdir _fchdir
#define fchmod _fchmod
#define fchown _fchown
#define fcntl _fcntl
#define flock _flock
#define fstatfs _fstatfs

View file

@ -24,7 +24,7 @@ SRCS+= accept.c access.c adjtime.c bind.c brk.c sbrk.c m_closefrom.c getsid.c \
_exit.c _ucontext.c environ.c __getcwd.c vfork.c sizeup.c init.c \
getrusage.c
# Minix specific syscalls.
SRCS+= cprofile.c lseek64.c sprofile.c stack_utils.c _mcontext.c
# Minix specific syscalls / utils.
SRCS+= cprofile.c sprofile.c stack_utils.c _mcontext.c
.include "${ARCHDIR}/sys-minix/Makefile.inc"

View file

@ -6,7 +6,7 @@
#include <unistd.h>
#ifdef __weak_alias
__weak_alias(chown, _chown)
__weak_alias(__posix_chown, chown)
#endif
int chown(const char *name, uid_t owner, gid_t grp)

View file

@ -6,7 +6,7 @@
#include <unistd.h>
#ifdef __weak_alias
__weak_alias(fchown, _fchown)
__weak_alias(__posix_fchown, fchown)
#endif
int fchown(int fd, uid_t owner, gid_t grp)

View file

@ -1,26 +0,0 @@
#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
#include <string.h>
#include <unistd.h>
#include <minix/u64.h>
int lseek64(fd, offset, whence, newpos)
int fd;
u64_t offset;
int whence;
u64_t *newpos;
{
message m;
memset(&m, 0, sizeof(m));
m.VFS_LSEEK_FD = fd;
m.VFS_LSEEK_OFF_LO = ex64lo(offset);
m.VFS_LSEEK_OFF_HI = ex64hi(offset);
m.VFS_LSEEK_WHENCE = whence;
if (_syscall(VFS_PROC_NR, VFS_LSEEK, &m) < 0) return -1;
if (newpos)
*newpos= make64(m.VFS_LSEEK_OFF_LO, m.VFS_LSEEK_OFF_HI);
return 0;
}

View file

@ -1,36 +1,13 @@
#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
#include <errno.h>
#include <unistd.h>
#ifdef __weak_alias
__weak_alias(pread, _pread)
#endif
#include <lib.h>
#include <unistd.h>
#include <minix/u64.h>
ssize_t pread64(int fd, void *buffer, size_t nbytes, u64_t where)
{
u64_t here;
ssize_t r;
if (lseek64(fd, make64(0,0), SEEK_CUR, &here) < 0) return(-1);
if (lseek64(fd, where, SEEK_SET, NULL) < 0) return(-1);
if ((r = read(fd, buffer, nbytes)) < 0) {
int e = errno;
lseek64(fd, here, SEEK_SET, NULL);
errno = e;
return(-1);
}
if (lseek64(fd, here, SEEK_SET, NULL) < 0) return(-1);
return(r);
}
ssize_t pread(int fd, void *buffer, size_t nbytes, off_t where)
{
off_t here;

View file

@ -1,34 +1,13 @@
#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
#include <errno.h>
#include <unistd.h>
#ifdef __weak_alias
__weak_alias(pwrite, _pwrite)
#endif
#include <minix/u64.h>
ssize_t pwrite64(int fd, const void *buffer, size_t nbytes, u64_t where)
{
u64_t here;
ssize_t w;
if (lseek64(fd, make64(0,0), SEEK_CUR, &here) < 0) return(-1);
if (lseek64(fd, where, SEEK_SET, NULL) < 0) return(-1);
if ((w = write(fd, buffer, nbytes)) < 0) {
int e = errno;
lseek64(fd, here, SEEK_SET, NULL);
errno = e;
return(-1);
}
if (lseek64(fd, here, SEEK_SET, NULL) < 0) return(-1);
return(w);
}
ssize_t pwrite(int fd, const void *buffer, size_t nbytes, off_t where)
{
off_t here;

View file

@ -145,7 +145,7 @@ CPPFLAGS.${i}+= -I${LIBCDIR}/locale
# Import from sys-minix
.for i in access.c brk.c close.c environ.c execve.c fork.c fsync.c \
getgid.c getpid.c geteuid.c getuid.c gettimeofday.c getvfsstat.c \
init.c link.c loadname.c lseek.c lseek64.c _mcontext.c mknod.c \
init.c link.c loadname.c lseek.c _mcontext.c mknod.c \
mmap.c nanosleep.c open.c pread.c pwrite.c read.c sbrk.c \
select.c setuid.c sigprocmask.c stack_utils.c stat.c stime.c \
syscall.c _ucontext.c umask.c unlink.c waitpid.c write.c \

View file

@ -318,23 +318,13 @@ bread(int fd, char *buf, daddr_t blk, long size)
offset = blk;
offset *= dev_bsize;
#ifndef __minix
if (lseek(fd, offset, 0) < 0)
rwerror("SEEK", blk);
#else
if (lseek64(fd, offset, 0, NULL) < 0)
rwerror("SEEK", blk);
#endif
else if (read(fd, buf, (int)size) == size)
return (0);
rwerror("READ", blk);
#ifndef __minix
if (lseek(fd, offset, 0) < 0)
rwerror("SEEK", blk);
#else
if (lseek64(fd, offset, 0, NULL) < 0)
rwerror("SEEK", blk);
#endif
errs = 0;
memset(buf, 0, (size_t)size);
printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
@ -370,25 +360,15 @@ bwrite(int fd, char *buf, daddr_t blk, long size)
return;
offset = blk;
offset *= dev_bsize;
#ifndef __minix
if (lseek(fd, offset, 0) < 0)
rwerror("SEEK", blk);
#else
if (lseek64(fd, offset, 0, NULL) < 0)
rwerror("SEEK", blk);
#endif
else if (write(fd, buf, (int)size) == size) {
fsmodified = 1;
return;
}
rwerror("WRITE", blk);
#ifndef __minix
if (lseek(fd, offset, 0) < 0)
rwerror("SEEK", blk);
#else
if (lseek64(fd, offset, 0, NULL) < 0)
rwerror("SEEK", blk);
#endif
printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
if (write(fd, cp, (int)dev_bsize) != dev_bsize) {

View file

@ -1385,18 +1385,10 @@ void
rdfs(daddr_t bno, int size, void *bf)
{
int n;
#ifndef __minix
off_t offset;
#else
u64_t offset;
#endif
offset = bno;
#ifndef __minix
n = pread(fsi, bf, size, offset * sectorsize);
#else
n = pread64(fsi, bf, size, offset * sectorsize);
#endif
if (n != size)
err(EXIT_FAILURE, "%s: read error for sector %" PRId64,
__func__, (int64_t)bno);
@ -1409,21 +1401,13 @@ void
wtfs(daddr_t bno, int size, void *bf)
{
int n;
#ifndef __minix
off_t offset;
#else
u64_t offset;
#endif
if (Nflag)
return;
offset = bno;
errno = 0;
#ifndef __minix
n = pwrite(fso, bf, size, offset * sectorsize);
#else
n = pwrite64(fso, bf, size, offset * sectorsize);
#endif
if (n != size)
err(EXIT_FAILURE, "%s: write error for sector %" PRId64,
__func__, (int64_t)bno);

View file

@ -1633,15 +1633,8 @@ static uint64_t
mkfs_seek(uint64_t pos, int whence)
{
if(whence == SEEK_SET) pos += fs_offset_bytes;
#ifdef __minix
uint64_t newpos;
if((lseek64(fd, pos, whence, &newpos)) < 0)
err(1, "mkfs_seek: lseek64 failed");
return newpos;
#else
off_t newpos;
if((newpos=lseek(fd, pos, whence)) == (off_t) -1)
err(1, "mkfs_seek: lseek failed");
return newpos;
#endif
}