Page MenuHomeFreeBSD

D9366.diff
No OneTemporary

D9366.diff

Index: head/sys/compat/cloudabi/cloudabi_fd.c
===================================================================
--- head/sys/compat/cloudabi/cloudabi_fd.c
+++ head/sys/compat/cloudabi/cloudabi_fd.c
@@ -209,26 +209,23 @@
int
cloudabi_sys_fd_seek(struct thread *td, struct cloudabi_sys_fd_seek_args *uap)
{
- struct lseek_args lseek_args = {
- .fd = uap->fd,
- .offset = uap->offset
- };
+ int whence;
switch (uap->whence) {
case CLOUDABI_WHENCE_CUR:
- lseek_args.whence = SEEK_CUR;
+ whence = SEEK_CUR;
break;
case CLOUDABI_WHENCE_END:
- lseek_args.whence = SEEK_END;
+ whence = SEEK_END;
break;
case CLOUDABI_WHENCE_SET:
- lseek_args.whence = SEEK_SET;
+ whence = SEEK_SET;
break;
default:
return (EINVAL);
}
- return (sys_lseek(td, &lseek_args));
+ return (kern_lseek(td, uap->fd, uap->offset, whence));
}
/* Converts a file descriptor to a CloudABI file descriptor type. */
Index: head/sys/compat/freebsd32/freebsd32_misc.c
===================================================================
--- head/sys/compat/freebsd32/freebsd32_misc.c
+++ head/sys/compat/freebsd32/freebsd32_misc.c
@@ -1477,12 +1477,8 @@
int
ofreebsd32_lseek(struct thread *td, struct ofreebsd32_lseek_args *uap)
{
- struct lseek_args nuap;
- nuap.fd = uap->fd;
- nuap.offset = uap->offset;
- nuap.whence = uap->whence;
- return (sys_lseek(td, &nuap));
+ return (kern_lseek(td, uap->fd, uap->offset, uap->whence));
}
#endif
@@ -1490,13 +1486,10 @@
freebsd32_lseek(struct thread *td, struct freebsd32_lseek_args *uap)
{
int error;
- struct lseek_args ap;
off_t pos;
- ap.fd = uap->fd;
- ap.offset = PAIR32TO64(off_t,uap->offset);
- ap.whence = uap->whence;
- error = sys_lseek(td, &ap);
+ error = kern_lseek(td, uap->fd, PAIR32TO64(off_t, uap->offset),
+ uap->whence);
/* Expand the quad return into two parts for eax and edx */
pos = td->td_uretoff.tdu_off;
td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */
@@ -1593,13 +1586,10 @@
freebsd6_freebsd32_lseek(struct thread *td, struct freebsd6_freebsd32_lseek_args *uap)
{
int error;
- struct lseek_args ap;
off_t pos;
- ap.fd = uap->fd;
- ap.offset = PAIR32TO64(off_t,uap->offset);
- ap.whence = uap->whence;
- error = sys_lseek(td, &ap);
+ error = kern_lseek(td, uap->fd, PAIR32TO64(off_t, uap->offset),
+ uap->whence);
/* Expand the quad return into two parts for eax and edx */
pos = *(off_t *)(td->td_retval);
td->td_retval[RETVAL_LO] = pos & 0xffffffff; /* %eax */
Index: head/sys/compat/linux/linux_file.c
===================================================================
--- head/sys/compat/linux/linux_file.c
+++ head/sys/compat/linux/linux_file.c
@@ -210,31 +210,19 @@
int
linux_lseek(struct thread *td, struct linux_lseek_args *args)
{
- struct lseek_args /* {
- int fd;
- int pad;
- off_t offset;
- int whence;
- } */ tmp_args;
- int error;
#ifdef DEBUG
if (ldebug(lseek))
printf(ARGS(lseek, "%d, %ld, %d"),
args->fdes, (long)args->off, args->whence);
#endif
- tmp_args.fd = args->fdes;
- tmp_args.offset = (off_t)args->off;
- tmp_args.whence = args->whence;
- error = sys_lseek(td, &tmp_args);
- return (error);
+ return (kern_lseek(td, args->fdes, args->off, args->whence));
}
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
int
linux_llseek(struct thread *td, struct linux_llseek_args *args)
{
- struct lseek_args bsd_args;
int error;
off_t off;
@@ -245,14 +233,12 @@
#endif
off = (args->olow) | (((off_t) args->ohigh) << 32);
- bsd_args.fd = args->fd;
- bsd_args.offset = off;
- bsd_args.whence = args->whence;
-
- if ((error = sys_lseek(td, &bsd_args)))
+ error = kern_lseek(td, args->fd, off, args->whence);
+ if (error != 0)
return (error);
- if ((error = copyout(td->td_retval, args->res, sizeof (off_t))))
+ error = copyout(td->td_retval, args->res, sizeof(off_t));
+ if (error != 0)
return (error);
td->td_retval[0] = 0;
Index: head/sys/kern/vfs_syscalls.c
===================================================================
--- head/sys/kern/vfs_syscalls.c
+++ head/sys/kern/vfs_syscalls.c
@@ -1806,25 +1806,25 @@
};
#endif
int
-sys_lseek(td, uap)
- struct thread *td;
- register struct lseek_args /* {
- int fd;
- int pad;
- off_t offset;
- int whence;
- } */ *uap;
+sys_lseek(struct thread *td, struct lseek_args *uap)
+{
+
+ return (kern_lseek(td, uap->fd, uap->offset, uap->whence));
+}
+
+int
+kern_lseek(struct thread *td, int fd, off_t offset, int whence)
{
struct file *fp;
cap_rights_t rights;
int error;
- AUDIT_ARG_FD(uap->fd);
- error = fget(td, uap->fd, cap_rights_init(&rights, CAP_SEEK), &fp);
+ AUDIT_ARG_FD(fd);
+ error = fget(td, fd, cap_rights_init(&rights, CAP_SEEK), &fp);
if (error != 0)
return (error);
error = (fp->f_ops->fo_flags & DFLAG_SEEKABLE) != 0 ?
- fo_seek(fp, uap->offset, uap->whence, td) : ESPIPE;
+ fo_seek(fp, offset, whence, td) : ESPIPE;
fdrop(fp, td);
return (error);
}
@@ -1841,41 +1841,20 @@
};
#endif
int
-olseek(td, uap)
- struct thread *td;
- register struct olseek_args /* {
- int fd;
- long offset;
- int whence;
- } */ *uap;
+olseek(struct thread *td, struct olseek_args *uap)
{
- struct lseek_args /* {
- int fd;
- int pad;
- off_t offset;
- int whence;
- } */ nuap;
- nuap.fd = uap->fd;
- nuap.offset = uap->offset;
- nuap.whence = uap->whence;
- return (sys_lseek(td, &nuap));
+ return (kern_lseek(td, uap->fd, uap->offset, uap->whence));
}
#endif /* COMPAT_43 */
#if defined(COMPAT_FREEBSD6)
/* Version with the 'pad' argument */
int
-freebsd6_lseek(td, uap)
- struct thread *td;
- register struct freebsd6_lseek_args *uap;
+freebsd6_lseek(struct thread *td, struct freebsd6_lseek_args *uap)
{
- struct lseek_args ouap;
- ouap.fd = uap->fd;
- ouap.offset = uap->offset;
- ouap.whence = uap->whence;
- return (sys_lseek(td, &ouap));
+ return (kern_lseek(td, uap->fd, uap->offset, uap->whence));
}
#endif
Index: head/sys/sys/syscallsubr.h
===================================================================
--- head/sys/sys/syscallsubr.h
+++ head/sys/sys/syscallsubr.h
@@ -135,6 +135,7 @@
int kern_kldunload(struct thread *td, int fileid, int flags);
int kern_linkat(struct thread *td, int fd1, int fd2, char *path1,
char *path2, enum uio_seg segflg, int follow);
+int kern_lseek(struct thread *td, int fd, off_t offset, int whence);
int kern_lutimes(struct thread *td, char *path, enum uio_seg pathseg,
struct timeval *tptr, enum uio_seg tptrseg);
int kern_mkdirat(struct thread *td, int fd, char *path,

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 27, 6:50 AM (2 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16188604
Default Alt Text
D9366.diff (6 KB)

Event Timeline