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:
parent
3160cdd5b1
commit
d3b0a89bab
18 changed files with 18 additions and 143 deletions
|
@ -1397,7 +1397,7 @@ ssize_t boot_readwrite(int rw)
|
||||||
{
|
{
|
||||||
int r = 0;
|
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;
|
return -1;
|
||||||
|
|
||||||
switch (rw) {
|
switch (rw) {
|
||||||
|
|
|
@ -412,9 +412,9 @@ int dir;
|
||||||
#if 0
|
#if 0
|
||||||
printf("%s at block %5d\n", dir == READING ? "reading " : "writing", bno);
|
printf("%s at block %5d\n", dir == READING ? "reading " : "writing", bno);
|
||||||
#endif
|
#endif
|
||||||
r= lseek64(dev, btoa64(bno), SEEK_SET, NULL);
|
r= lseek(dev, btoa64(bno), SEEK_SET);
|
||||||
if (r != 0)
|
if (r < 0)
|
||||||
fatal("lseek64 failed");
|
fatal("lseek failed");
|
||||||
if (dir == READING) {
|
if (dir == READING) {
|
||||||
if (read(dev, rwbuf, block_size) == block_size)
|
if (read(dev, rwbuf, block_size) == block_size)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1578,7 +1578,7 @@ ssize_t boot_readwrite(int rw)
|
||||||
{
|
{
|
||||||
int r = 0;
|
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;
|
return -1;
|
||||||
|
|
||||||
switch (rw) {
|
switch (rw) {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <minix/type.h>
|
||||||
|
|
||||||
#include "tdist.h"
|
#include "tdist.h"
|
||||||
|
|
||||||
|
|
|
@ -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. */
|
/* For reads, read in the data for the chunk; possibly less. */
|
||||||
if (!do_write) {
|
if (!do_write) {
|
||||||
chunk = r = pread64(state.fd, state.buf, chunk,
|
chunk = r = pread(state.fd, state.buf, chunk,
|
||||||
position);
|
position);
|
||||||
|
|
||||||
if (r < 0) {
|
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. */
|
/* For writes, write the data to the file; possibly less. */
|
||||||
if (do_write) {
|
if (do_write) {
|
||||||
chunk = r = pwrite64(state.fd, state.buf, chunk,
|
chunk = r = pwrite(state.fd, state.buf, chunk,
|
||||||
position);
|
position);
|
||||||
|
|
||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
|
|
|
@ -36,7 +36,4 @@ void _loadname(const char *_name, message *_msgptr);
|
||||||
int _len(const char *_s);
|
int _len(const char *_s);
|
||||||
void _begsig(int _dummy);
|
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 */
|
#endif /* _LIB_H */
|
||||||
|
|
|
@ -88,7 +88,7 @@ __dead void _exit(int);
|
||||||
int access(const char *, int);
|
int access(const char *, int);
|
||||||
unsigned int alarm(unsigned int);
|
unsigned int alarm(unsigned int);
|
||||||
int chdir(const char *);
|
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);
|
int chown(const char *, uid_t, gid_t) __RENAME(__posix_chown);
|
||||||
#else
|
#else
|
||||||
int chown(const char *, uid_t, gid_t);
|
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 || \
|
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||||
defined(_NETBSD_SOURCE)
|
defined(_NETBSD_SOURCE)
|
||||||
#ifndef __minix
|
#ifndef __minix
|
||||||
int fdatasync(int);
|
int fdatasync(int);
|
||||||
#endif /* !__minix */
|
#endif /* !__minix */
|
||||||
int fsync(int);
|
int fsync(int);
|
||||||
|
@ -247,7 +247,7 @@ typedef __intptr_t intptr_t;
|
||||||
|
|
||||||
int brk(void *);
|
int brk(void *);
|
||||||
int fchdir(int);
|
int fchdir(int);
|
||||||
#if !defined(__minix) && defined(_XOPEN_SOURCE)
|
#if defined(_XOPEN_SOURCE)
|
||||||
int fchown(int, uid_t, gid_t) __RENAME(__posix_fchown);
|
int fchown(int, uid_t, gid_t) __RENAME(__posix_fchown);
|
||||||
#else
|
#else
|
||||||
int fchown(int, uid_t, gid_t);
|
int fchown(int, uid_t, gid_t);
|
||||||
|
@ -321,14 +321,6 @@ int unlinkat(int, const char *, int);
|
||||||
/*
|
/*
|
||||||
* Implementation-defined extensions
|
* 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)
|
#if defined(_NETBSD_SOURCE)
|
||||||
#ifndef __minix
|
#ifndef __minix
|
||||||
int acct(const char *);
|
int acct(const char *);
|
||||||
|
|
|
@ -864,7 +864,6 @@
|
||||||
#define bind _bind
|
#define bind _bind
|
||||||
#define chdir _chdir
|
#define chdir _chdir
|
||||||
#define chmod _chmod
|
#define chmod _chmod
|
||||||
#define chown _chown
|
|
||||||
#define chroot _chroot
|
#define chroot _chroot
|
||||||
#define close _close
|
#define close _close
|
||||||
#define dup _dup
|
#define dup _dup
|
||||||
|
@ -872,7 +871,6 @@
|
||||||
#define execve _execve
|
#define execve _execve
|
||||||
#define fchdir _fchdir
|
#define fchdir _fchdir
|
||||||
#define fchmod _fchmod
|
#define fchmod _fchmod
|
||||||
#define fchown _fchown
|
|
||||||
#define fcntl _fcntl
|
#define fcntl _fcntl
|
||||||
#define flock _flock
|
#define flock _flock
|
||||||
#define fstatfs _fstatfs
|
#define fstatfs _fstatfs
|
||||||
|
|
|
@ -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 \
|
_exit.c _ucontext.c environ.c __getcwd.c vfork.c sizeup.c init.c \
|
||||||
getrusage.c
|
getrusage.c
|
||||||
|
|
||||||
# Minix specific syscalls.
|
# Minix specific syscalls / utils.
|
||||||
SRCS+= cprofile.c lseek64.c sprofile.c stack_utils.c _mcontext.c
|
SRCS+= cprofile.c sprofile.c stack_utils.c _mcontext.c
|
||||||
|
|
||||||
.include "${ARCHDIR}/sys-minix/Makefile.inc"
|
.include "${ARCHDIR}/sys-minix/Makefile.inc"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef __weak_alias
|
#ifdef __weak_alias
|
||||||
__weak_alias(chown, _chown)
|
__weak_alias(__posix_chown, chown)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int chown(const char *name, uid_t owner, gid_t grp)
|
int chown(const char *name, uid_t owner, gid_t grp)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef __weak_alias
|
#ifdef __weak_alias
|
||||||
__weak_alias(fchown, _fchown)
|
__weak_alias(__posix_fchown, fchown)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int fchown(int fd, uid_t owner, gid_t grp)
|
int fchown(int fd, uid_t owner, gid_t grp)
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
|
@ -1,36 +1,13 @@
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include "namespace.h"
|
#include "namespace.h"
|
||||||
#include <lib.h>
|
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef __weak_alias
|
#ifdef __weak_alias
|
||||||
__weak_alias(pread, _pread)
|
__weak_alias(pread, _pread)
|
||||||
#endif
|
#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)
|
ssize_t pread(int fd, void *buffer, size_t nbytes, off_t where)
|
||||||
{
|
{
|
||||||
off_t here;
|
off_t here;
|
||||||
|
|
|
@ -1,34 +1,13 @@
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include "namespace.h"
|
#include "namespace.h"
|
||||||
#include <lib.h>
|
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef __weak_alias
|
#ifdef __weak_alias
|
||||||
__weak_alias(pwrite, _pwrite)
|
__weak_alias(pwrite, _pwrite)
|
||||||
#endif
|
#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)
|
ssize_t pwrite(int fd, const void *buffer, size_t nbytes, off_t where)
|
||||||
{
|
{
|
||||||
off_t here;
|
off_t here;
|
||||||
|
|
|
@ -145,7 +145,7 @@ CPPFLAGS.${i}+= -I${LIBCDIR}/locale
|
||||||
# Import from sys-minix
|
# Import from sys-minix
|
||||||
.for i in access.c brk.c close.c environ.c execve.c fork.c fsync.c \
|
.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 \
|
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 \
|
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 \
|
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 \
|
syscall.c _ucontext.c umask.c unlink.c waitpid.c write.c \
|
||||||
|
|
|
@ -318,23 +318,13 @@ bread(int fd, char *buf, daddr_t blk, long size)
|
||||||
|
|
||||||
offset = blk;
|
offset = blk;
|
||||||
offset *= dev_bsize;
|
offset *= dev_bsize;
|
||||||
#ifndef __minix
|
|
||||||
if (lseek(fd, offset, 0) < 0)
|
if (lseek(fd, offset, 0) < 0)
|
||||||
rwerror("SEEK", blk);
|
rwerror("SEEK", blk);
|
||||||
#else
|
|
||||||
if (lseek64(fd, offset, 0, NULL) < 0)
|
|
||||||
rwerror("SEEK", blk);
|
|
||||||
#endif
|
|
||||||
else if (read(fd, buf, (int)size) == size)
|
else if (read(fd, buf, (int)size) == size)
|
||||||
return (0);
|
return (0);
|
||||||
rwerror("READ", blk);
|
rwerror("READ", blk);
|
||||||
#ifndef __minix
|
|
||||||
if (lseek(fd, offset, 0) < 0)
|
if (lseek(fd, offset, 0) < 0)
|
||||||
rwerror("SEEK", blk);
|
rwerror("SEEK", blk);
|
||||||
#else
|
|
||||||
if (lseek64(fd, offset, 0, NULL) < 0)
|
|
||||||
rwerror("SEEK", blk);
|
|
||||||
#endif
|
|
||||||
errs = 0;
|
errs = 0;
|
||||||
memset(buf, 0, (size_t)size);
|
memset(buf, 0, (size_t)size);
|
||||||
printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
|
printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
|
||||||
|
@ -370,25 +360,15 @@ bwrite(int fd, char *buf, daddr_t blk, long size)
|
||||||
return;
|
return;
|
||||||
offset = blk;
|
offset = blk;
|
||||||
offset *= dev_bsize;
|
offset *= dev_bsize;
|
||||||
#ifndef __minix
|
|
||||||
if (lseek(fd, offset, 0) < 0)
|
if (lseek(fd, offset, 0) < 0)
|
||||||
rwerror("SEEK", blk);
|
rwerror("SEEK", blk);
|
||||||
#else
|
|
||||||
if (lseek64(fd, offset, 0, NULL) < 0)
|
|
||||||
rwerror("SEEK", blk);
|
|
||||||
#endif
|
|
||||||
else if (write(fd, buf, (int)size) == size) {
|
else if (write(fd, buf, (int)size) == size) {
|
||||||
fsmodified = 1;
|
fsmodified = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rwerror("WRITE", blk);
|
rwerror("WRITE", blk);
|
||||||
#ifndef __minix
|
|
||||||
if (lseek(fd, offset, 0) < 0)
|
if (lseek(fd, offset, 0) < 0)
|
||||||
rwerror("SEEK", blk);
|
rwerror("SEEK", blk);
|
||||||
#else
|
|
||||||
if (lseek64(fd, offset, 0, NULL) < 0)
|
|
||||||
rwerror("SEEK", blk);
|
|
||||||
#endif
|
|
||||||
printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
|
printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
|
||||||
for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
|
for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
|
||||||
if (write(fd, cp, (int)dev_bsize) != dev_bsize) {
|
if (write(fd, cp, (int)dev_bsize) != dev_bsize) {
|
||||||
|
|
|
@ -1385,18 +1385,10 @@ void
|
||||||
rdfs(daddr_t bno, int size, void *bf)
|
rdfs(daddr_t bno, int size, void *bf)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
#ifndef __minix
|
|
||||||
off_t offset;
|
off_t offset;
|
||||||
#else
|
|
||||||
u64_t offset;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
offset = bno;
|
offset = bno;
|
||||||
#ifndef __minix
|
|
||||||
n = pread(fsi, bf, size, offset * sectorsize);
|
n = pread(fsi, bf, size, offset * sectorsize);
|
||||||
#else
|
|
||||||
n = pread64(fsi, bf, size, offset * sectorsize);
|
|
||||||
#endif
|
|
||||||
if (n != size)
|
if (n != size)
|
||||||
err(EXIT_FAILURE, "%s: read error for sector %" PRId64,
|
err(EXIT_FAILURE, "%s: read error for sector %" PRId64,
|
||||||
__func__, (int64_t)bno);
|
__func__, (int64_t)bno);
|
||||||
|
@ -1409,21 +1401,13 @@ void
|
||||||
wtfs(daddr_t bno, int size, void *bf)
|
wtfs(daddr_t bno, int size, void *bf)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
#ifndef __minix
|
|
||||||
off_t offset;
|
off_t offset;
|
||||||
#else
|
|
||||||
u64_t offset;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (Nflag)
|
if (Nflag)
|
||||||
return;
|
return;
|
||||||
offset = bno;
|
offset = bno;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
#ifndef __minix
|
|
||||||
n = pwrite(fso, bf, size, offset * sectorsize);
|
n = pwrite(fso, bf, size, offset * sectorsize);
|
||||||
#else
|
|
||||||
n = pwrite64(fso, bf, size, offset * sectorsize);
|
|
||||||
#endif
|
|
||||||
if (n != size)
|
if (n != size)
|
||||||
err(EXIT_FAILURE, "%s: write error for sector %" PRId64,
|
err(EXIT_FAILURE, "%s: write error for sector %" PRId64,
|
||||||
__func__, (int64_t)bno);
|
__func__, (int64_t)bno);
|
||||||
|
|
|
@ -1633,15 +1633,8 @@ static uint64_t
|
||||||
mkfs_seek(uint64_t pos, int whence)
|
mkfs_seek(uint64_t pos, int whence)
|
||||||
{
|
{
|
||||||
if(whence == SEEK_SET) pos += fs_offset_bytes;
|
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;
|
off_t newpos;
|
||||||
if((newpos=lseek(fd, pos, whence)) == (off_t) -1)
|
if((newpos=lseek(fd, pos, whence)) == (off_t) -1)
|
||||||
err(1, "mkfs_seek: lseek failed");
|
err(1, "mkfs_seek: lseek failed");
|
||||||
return newpos;
|
return newpos;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue