Module Name:    src
Committed By:   pooka
Date:           Mon Feb 21 12:51:06 UTC 2011

Modified Files:
        src/lib/librumphijack: hijack.c

Log Message:
hijack:
  1) {,f,l}chflags (used e.g. by cp(1))
  2) p{read,write}{,v} (used by many)


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.59 src/lib/librumphijack/hijack.c:1.60
--- src/lib/librumphijack/hijack.c:1.59	Sun Feb 20 23:47:04 2011
+++ src/lib/librumphijack/hijack.c	Mon Feb 21 12:51:06 2011
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.59 2011/02/20 23:47:04 pooka Exp $	*/
+/*      $NetBSD: hijack.c,v 1.60 2011/02/21 12:51:06 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: hijack.c,v 1.59 2011/02/20 23:47:04 pooka Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.60 2011/02/21 12:51:06 pooka Exp $");
 
 #define __ssp_weak_name(fun) _hijack_ ## fun
 
@@ -59,7 +59,7 @@
 #include <unistd.h>
 
 enum dualcall {
-	DUALCALL_WRITE, DUALCALL_WRITEV,
+	DUALCALL_WRITE, DUALCALL_WRITEV, DUALCALL_PWRITE, DUALCALL_PWRITEV,
 	DUALCALL_IOCTL, DUALCALL_FCNTL,
 	DUALCALL_SOCKET, DUALCALL_ACCEPT, DUALCALL_BIND, DUALCALL_CONNECT,
 	DUALCALL_GETPEERNAME, DUALCALL_GETSOCKNAME, DUALCALL_LISTEN,
@@ -67,7 +67,7 @@
 	DUALCALL_SENDTO, DUALCALL_SENDMSG,
 	DUALCALL_GETSOCKOPT, DUALCALL_SETSOCKOPT,
 	DUALCALL_SHUTDOWN,
-	DUALCALL_READ, DUALCALL_READV,
+	DUALCALL_READ, DUALCALL_READV, DUALCALL_PREAD, DUALCALL_PREADV,
 	DUALCALL_DUP2,
 	DUALCALL_CLOSE,
 	DUALCALL_POLLTS,
@@ -88,6 +88,7 @@
 	DUALCALL_FSYNC, DUALCALL_FSYNC_RANGE,
 	DUALCALL_MOUNT, DUALCALL_UNMOUNT,
 	DUALCALL___GETCWD,
+	DUALCALL_CHFLAGS, DUALCALL_LCHFLAGS, DUALCALL_FCHFLAGS,
 	DUALCALL__NUM
 };
 
@@ -120,6 +121,8 @@
 #define REALFUTIMES __futimes50
 #endif
 #define REALREAD _sys_read
+#define REALPREAD _sys_pread
+#define REALPWRITE _sys_pwrite
 #define REALGETDENTS __getdents30
 #define REALMOUNT __mount50
 #define REALLSEEK _lseek
@@ -130,6 +133,8 @@
 int REALKEVENT(int, const struct kevent *, size_t, struct kevent *, size_t,
 	       const struct timespec *);
 ssize_t REALREAD(int, void *, size_t);
+ssize_t REALPREAD(int, void *, size_t, off_t);
+ssize_t REALPWRITE(int, const void *, size_t, off_t);
 int REALSTAT(const char *, struct stat *);
 int REALLSTAT(const char *, struct stat *);
 int REALFSTAT(int, struct stat *);
@@ -163,8 +168,12 @@
 	{ DUALCALL_SHUTDOWN,	"shutdown",	RSYS_NAME(SHUTDOWN)	},
 	{ DUALCALL_READ,	S(REALREAD),	RSYS_NAME(READ)		},
 	{ DUALCALL_READV,	"readv",	RSYS_NAME(READV)	},
+	{ DUALCALL_PREAD,	S(REALPREAD),	RSYS_NAME(PREAD)	},
+	{ DUALCALL_PREADV,	"preadv",	RSYS_NAME(PREADV)	},
 	{ DUALCALL_WRITE,	"write",	RSYS_NAME(WRITE)	},
 	{ DUALCALL_WRITEV,	"writev",	RSYS_NAME(WRITEV)	},
+	{ DUALCALL_PWRITE,	S(REALPWRITE),	RSYS_NAME(PWRITE)	},
+	{ DUALCALL_PWRITEV,	"pwritev",	RSYS_NAME(PWRITEV)	},
 	{ DUALCALL_IOCTL,	"ioctl",	RSYS_NAME(IOCTL)	},
 	{ DUALCALL_FCNTL,	"fcntl",	RSYS_NAME(FCNTL)	},
 	{ DUALCALL_DUP2,	"dup2",		RSYS_NAME(DUP2)		},
@@ -203,6 +212,9 @@
 	{ DUALCALL_MOUNT,	S(REALMOUNT),	RSYS_NAME(MOUNT)	},
 	{ DUALCALL_UNMOUNT,	"unmount",	RSYS_NAME(UNMOUNT)	},
 	{ DUALCALL___GETCWD,	"__getcwd",	RSYS_NAME(__GETCWD)	},
+	{ DUALCALL_CHFLAGS,	"chflags",	RSYS_NAME(CHFLAGS)	},
+	{ DUALCALL_LCHFLAGS,	"lchflags",	RSYS_NAME(LCHFLAGS)	},
+	{ DUALCALL_FCHFLAGS,	"fchflags",	RSYS_NAME(FCHFLAGS)	},
 };
 #undef S
 
@@ -1614,11 +1626,31 @@
 	(int, const struct iovec *, int),				\
 	(fd, iov, iovcnt))
 
+FDCALL(ssize_t, REALPREAD, DUALCALL_PREAD,				\
+	(int fd, void *buf, size_t nbytes, off_t offset),		\
+	(int, void *, size_t, off_t),					\
+	(fd, buf, nbytes, offset))
+
+FDCALL(ssize_t, preadv, DUALCALL_PREADV, 				\
+	(int fd, const struct iovec *iov, int iovcnt, off_t offset),	\
+	(int, const struct iovec *, int, off_t),			\
+	(fd, iov, iovcnt, offset))
+
 FDCALL(ssize_t, writev, DUALCALL_WRITEV, 				\
 	(int fd, const struct iovec *iov, int iovcnt),			\
 	(int, const struct iovec *, int),				\
 	(fd, iov, iovcnt))
 
+FDCALL(ssize_t, REALPWRITE, DUALCALL_PWRITE,				\
+	(int fd, const void *buf, size_t nbytes, off_t offset),		\
+	(int, const void *, size_t, off_t),				\
+	(fd, buf, nbytes, offset))
+
+FDCALL(ssize_t, pwritev, DUALCALL_PWRITEV, 				\
+	(int fd, const struct iovec *iov, int iovcnt, off_t offset),	\
+	(int, const struct iovec *, int, off_t),			\
+	(fd, iov, iovcnt, offset))
+
 FDCALL(int, REALFSTAT, DUALCALL_FSTAT,					\
 	(int fd, struct stat *sb),					\
 	(int, struct stat *),						\
@@ -1669,6 +1701,11 @@
 	(int, const struct timeval *),					\
 	(fd, tv))
 
+FDCALL(int, fchflags, DUALCALL_FCHFLAGS,				\
+	(int fd, u_long flags),						\
+	(int, u_long),							\
+	(fd, flags))
+
 /*
  * path-based selectors
  */
@@ -1743,6 +1780,16 @@
 	(const char *, const struct timeval *),				\
 	(path, tv))
 
+PATHCALL(int, chflags, DUALCALL_CHFLAGS,				\
+	(const char *path, u_long flags),				\
+	(const char *, u_long),						\
+	(path, flags))
+
+PATHCALL(int, lchflags, DUALCALL_LCHFLAGS,				\
+	(const char *path, u_long flags),				\
+	(const char *, u_long),						\
+	(path, flags))
+
 PATHCALL(int, truncate, DUALCALL_TRUNCATE,				\
 	(const char *path, off_t length),				\
 	(const char *, off_t),						\

Reply via email to