From d3b0a89babce917eb113c8a8f73555e278f60286 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Mon, 2 Dec 2013 20:03:35 +0100 Subject: [PATCH] include/unistd.h: merged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also removing lseek64, pread64, pwrite64. Those functions have lost their "raison d'ĂȘtre", when off_t switched to 64bits. Change-Id: I5aea35f01d6d10e3d6578a70323da7be5eca315a --- commands/autopart/autopart.c | 2 +- commands/fsck.mfs/fsck.c | 6 +++--- commands/part/part.c | 2 +- commands/sprofdiff/sprofdiff.c | 1 + drivers/vnd/vnd.c | 4 ++-- include/lib.h | 3 --- include/unistd.h | 14 +++----------- lib/libc/include/namespace.h | 2 -- lib/libc/sys-minix/Makefile.inc | 4 ++-- lib/libc/sys-minix/chown.c | 2 +- lib/libc/sys-minix/fchown.c | 2 +- lib/libc/sys-minix/lseek64.c | 26 -------------------------- lib/libc/sys-minix/pread.c | 25 +------------------------ lib/libc/sys-minix/pwrite.c | 23 +---------------------- lib/libminc/Makefile | 2 +- sbin/fsck_ext2fs/utilities.c | 20 -------------------- sbin/newfs_ext2fs/mke2fs.c | 16 ---------------- usr.sbin/mkfs.mfs/mkfs.c | 7 ------- 18 files changed, 18 insertions(+), 143 deletions(-) delete mode 100644 lib/libc/sys-minix/lseek64.c diff --git a/commands/autopart/autopart.c b/commands/autopart/autopart.c index 00146098d..4a47c3ad2 100644 --- a/commands/autopart/autopart.c +++ b/commands/autopart/autopart.c @@ -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) { diff --git a/commands/fsck.mfs/fsck.c b/commands/fsck.mfs/fsck.c index 3cf242dcb..48c63c58a 100644 --- a/commands/fsck.mfs/fsck.c +++ b/commands/fsck.mfs/fsck.c @@ -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; diff --git a/commands/part/part.c b/commands/part/part.c index 2bf169cf9..66c60b0d5 100644 --- a/commands/part/part.c +++ b/commands/part/part.c @@ -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) { diff --git a/commands/sprofdiff/sprofdiff.c b/commands/sprofdiff/sprofdiff.c index 9232a089e..800956144 100755 --- a/commands/sprofdiff/sprofdiff.c +++ b/commands/sprofdiff/sprofdiff.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "tdist.h" diff --git a/drivers/vnd/vnd.c b/drivers/vnd/vnd.c index bf55d18cf..5fabcdd31 100644 --- a/drivers/vnd/vnd.c +++ b/drivers/vnd/vnd.c @@ -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) { diff --git a/include/lib.h b/include/lib.h index f5d15cf07..f3df2951f 100644 --- a/include/lib.h +++ b/include/lib.h @@ -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 */ diff --git a/include/unistd.h b/include/unistd.h index c50e91d0d..128ab50da 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -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 -#endif /* defined(_NETBSD_SOURCE) */ -#endif /* __minix */ - #if defined(_NETBSD_SOURCE) #ifndef __minix int acct(const char *); diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h index 74337eecd..ed48bc5e1 100644 --- a/lib/libc/include/namespace.h +++ b/lib/libc/include/namespace.h @@ -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 diff --git a/lib/libc/sys-minix/Makefile.inc b/lib/libc/sys-minix/Makefile.inc index c4194b635..2dea8f10d 100644 --- a/lib/libc/sys-minix/Makefile.inc +++ b/lib/libc/sys-minix/Makefile.inc @@ -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" diff --git a/lib/libc/sys-minix/chown.c b/lib/libc/sys-minix/chown.c index f6d5517e5..b0505971a 100644 --- a/lib/libc/sys-minix/chown.c +++ b/lib/libc/sys-minix/chown.c @@ -6,7 +6,7 @@ #include #ifdef __weak_alias -__weak_alias(chown, _chown) +__weak_alias(__posix_chown, chown) #endif int chown(const char *name, uid_t owner, gid_t grp) diff --git a/lib/libc/sys-minix/fchown.c b/lib/libc/sys-minix/fchown.c index d3538562f..b49601c85 100644 --- a/lib/libc/sys-minix/fchown.c +++ b/lib/libc/sys-minix/fchown.c @@ -6,7 +6,7 @@ #include #ifdef __weak_alias -__weak_alias(fchown, _fchown) +__weak_alias(__posix_fchown, fchown) #endif int fchown(int fd, uid_t owner, gid_t grp) diff --git a/lib/libc/sys-minix/lseek64.c b/lib/libc/sys-minix/lseek64.c deleted file mode 100644 index b75b1322d..000000000 --- a/lib/libc/sys-minix/lseek64.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include "namespace.h" -#include - -#include -#include -#include - -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; -} diff --git a/lib/libc/sys-minix/pread.c b/lib/libc/sys-minix/pread.c index f2b751544..d5dd1e57e 100644 --- a/lib/libc/sys-minix/pread.c +++ b/lib/libc/sys-minix/pread.c @@ -1,36 +1,13 @@ #include #include "namespace.h" -#include +#include #include #ifdef __weak_alias __weak_alias(pread, _pread) #endif -#include -#include -#include - -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; diff --git a/lib/libc/sys-minix/pwrite.c b/lib/libc/sys-minix/pwrite.c index f2c07b3a4..d36b1ec21 100644 --- a/lib/libc/sys-minix/pwrite.c +++ b/lib/libc/sys-minix/pwrite.c @@ -1,34 +1,13 @@ #include #include "namespace.h" -#include +#include #include #ifdef __weak_alias __weak_alias(pwrite, _pwrite) #endif -#include - -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; diff --git a/lib/libminc/Makefile b/lib/libminc/Makefile index 286082498..aa3eeb8fb 100644 --- a/lib/libminc/Makefile +++ b/lib/libminc/Makefile @@ -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 \ diff --git a/sbin/fsck_ext2fs/utilities.c b/sbin/fsck_ext2fs/utilities.c index 116937876..59920d2c5 100644 --- a/sbin/fsck_ext2fs/utilities.c +++ b/sbin/fsck_ext2fs/utilities.c @@ -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) { diff --git a/sbin/newfs_ext2fs/mke2fs.c b/sbin/newfs_ext2fs/mke2fs.c index 71ae78671..ef86c8f3f 100644 --- a/sbin/newfs_ext2fs/mke2fs.c +++ b/sbin/newfs_ext2fs/mke2fs.c @@ -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); diff --git a/usr.sbin/mkfs.mfs/mkfs.c b/usr.sbin/mkfs.mfs/mkfs.c index 9ceb85dab..b1037ad7f 100644 --- a/usr.sbin/mkfs.mfs/mkfs.c +++ b/usr.sbin/mkfs.mfs/mkfs.c @@ -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 }