Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/irix Added an ioctl emulation so that IRIX's tar ...



details:   https://anonhg.NetBSD.org/src/rev/91812da924fc
branches:  trunk
changeset: 537800:91812da924fc
user:      manu <manu%NetBSD.org@localhost>
date:      Sat Oct 05 21:29:02 2002 +0000

description:
Added an ioctl emulation so that IRIX's tar is able to extract a file.

diffstat:

 sys/compat/irix/irix_ioctl.c |  42 +++++++++++++++++++++++++++++++++++++++---
 sys/compat/irix/irix_ioctl.h |   6 +++++-
 2 files changed, 44 insertions(+), 4 deletions(-)

diffs (98 lines):

diff -r d45b5864cc1e -r 91812da924fc sys/compat/irix/irix_ioctl.c
--- a/sys/compat/irix/irix_ioctl.c      Sat Oct 05 21:29:01 2002 +0000
+++ b/sys/compat/irix/irix_ioctl.c      Sat Oct 05 21:29:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irix_ioctl.c,v 1.4 2002/09/06 13:18:43 gehenna Exp $ */
+/*     $NetBSD: irix_ioctl.c,v 1.5 2002/10/05 21:29:02 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_ioctl.c,v 1.4 2002/09/06 13:18:43 gehenna Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_ioctl.c,v 1.5 2002/10/05 21:29:02 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -87,10 +87,11 @@
        struct file *fp;
        struct filedesc *fdp;
        struct vnode *vp;
+       struct vattr vattr;
        struct irix_ioctl_usrdata iiu;
        struct irix_ioctl_usrdata *iiup;
        caddr_t sg = stackgap_init(p, 0);
-       int error;
+       int error, val;
 
        /* 
         * This duplicates 6 lines from svr4_sys_ioctl() 
@@ -120,6 +121,8 @@
         * are defined _IO but really are _IOR. XXX need security review.
         */
        if ((cmd & IRIX_UIOC_MASK) == IRIX_UIOC) {
+               if (fp->f_type != DTYPE_VNODE)
+                       return ENOTTY;
                FILE_USE(fp);
                vp = (struct vnode*)fp->f_data;
                if (vp->v_type != VCHR ||
@@ -148,6 +151,39 @@
                    SCARG(uap, data), p);
                break;  
 
+       case IRIX_MTIOCGETBLKSIZE: /* get tape block size in 512B units */
+               if (fp->f_type != DTYPE_VNODE)
+                       return ENOSYS;
+
+               FILE_USE(fp);
+               vp = (struct vnode*)fp->f_data;
+
+               switch (vp->v_type) {
+               case VREG:
+               case VLNK:
+               case VDIR:
+                       error = ENOTTY;
+                       break;
+               case VCHR:
+               case VFIFO:
+                       error = EINVAL;
+                       break;
+               case VBLK:
+                       error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
+                       if (error == 0) {
+                               val = vattr.va_blocksize / 512;
+                               error = copyout(&val, data, sizeof(int));
+                       }
+
+               default:
+                       error = ENOSYS;
+                       break;
+               }
+
+               FILE_UNUSE(fp, p);
+               return error;
+               break;
+
        default: /* Fallback to the standard SVR4 ioctl's */
                error = svr4_sys_ioctl(p, v, retval);
                break;
diff -r d45b5864cc1e -r 91812da924fc sys/compat/irix/irix_ioctl.h
--- a/sys/compat/irix/irix_ioctl.h      Sat Oct 05 21:29:01 2002 +0000
+++ b/sys/compat/irix/irix_ioctl.h      Sat Oct 05 21:29:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irix_ioctl.h,v 1.2 2002/05/22 05:14:01 manu Exp $ */
+/*     $NetBSD: irix_ioctl.h,v 1.3 2002/10/05 21:29:02 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -49,4 +49,8 @@
 /* From IRIX's <net/raw.h> */
 #define IRIX_SIOCNREAD SVR4_IOR('s', 10, int) 
 
+/* From IRIX's <sys/mtio.h> */
+#define IRIX_MTIOCODE(x)     ('t'<<8|(x))
+#define IRIX_MTIOCGETBLKSIZE IRIX_MTIOCODE('c')
+
 #endif /* _IRIX_IOCTL_H_ */



Home | Main Index | Thread Index | Old Index