Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/osf1 emulate (parts of) flock



details:   https://anonhg.NetBSD.org/src/rev/fa718894ebad
branches:  trunk
changeset: 474018:fa718894ebad
user:      cgd <cgd%NetBSD.org@localhost>
date:      Sat Jun 26 01:24:41 1999 +0000

description:
emulate (parts of) flock

diffstat:

 sys/compat/osf1/osf1_descrip.c |  40 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 4 deletions(-)

diffs (74 lines):

diff -r 72c50f921775 -r fa718894ebad sys/compat/osf1/osf1_descrip.c
--- a/sys/compat/osf1/osf1_descrip.c    Sat Jun 26 01:23:23 1999 +0000
+++ b/sys/compat/osf1/osf1_descrip.c    Sat Jun 26 01:24:41 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: osf1_descrip.c,v 1.4 1999/05/05 20:01:04 thorpej Exp $ */
+/* $NetBSD: osf1_descrip.c,v 1.5 1999/06/26 01:24:41 cgd Exp $ */
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -92,9 +92,14 @@
 {
        struct osf1_sys_fcntl_args *uap = v;
        struct sys_fcntl_args a;
+       struct osf1_flock oflock;
+       struct flock nflock;
        unsigned long xfl, leftovers;
+       caddr_t sg;
        int error;
 
+       sg = stackgap_init(p->p_emul);
+
        SCARG(&a, fd) = SCARG(uap, fd);
 
        leftovers = 0;
@@ -132,12 +137,30 @@
 
        case OSF1_F_GETOWN:             /* XXX not yet supported */
        case OSF1_F_SETOWN:             /* XXX not yet supported */
-       case OSF1_F_GETLK:              /* XXX not yet supported */
-       case OSF1_F_SETLK:              /* XXX not yet supported */
-       case OSF1_F_SETLKW:             /* XXX not yet supported */
                /* XXX translate. */
                return (EINVAL);
                
+       case OSF1_F_GETLK:
+       case OSF1_F_SETLK:
+       case OSF1_F_SETLKW:
+               if (SCARG(uap, cmd) == OSF1_F_GETLK)
+                       SCARG(&a, cmd) = F_GETLK;
+               else if (SCARG(uap, cmd) == OSF1_F_SETLK)
+                       SCARG(&a, cmd) = F_SETLK;
+               else if (SCARG(uap, cmd) == OSF1_F_SETLKW)
+                       SCARG(&a, cmd) = F_SETLKW;
+               SCARG(&a, arg) = stackgap_alloc(&sg, sizeof nflock);
+
+               error = copyin(SCARG(uap, arg), &oflock, sizeof oflock);
+               if (error == 0)
+                       error = osf1_cvt_flock_to_native(&oflock, &nflock);
+               if (error == 0)
+                       error = copyout(&nflock, SCARG(&a, arg),
+                           sizeof nflock);
+               if (error != 0)
+                       return (error);
+               break;
+               
        case OSF1_F_RGETLK:             /* [lock mgr op] XXX not supported */
        case OSF1_F_RSETLK:             /* [lock mgr op] XXX not supported */
        case OSF1_F_CNVT:               /* [lock mgr op] XXX not supported */
@@ -169,6 +192,15 @@
                    leftovers, NULL);
                retval[0] = xfl;
                break;
+
+       case OSF1_F_GETLK:
+               error = copyin(SCARG(&a, arg), &nflock, sizeof nflock);
+               if (error == 0) {
+                       osf1_cvt_flock_from_native(&nflock, &oflock);
+                       error = copyout(&oflock, SCARG(uap, arg),
+                           sizeof oflock);
+               }
+               break;
        }
 
        return error;



Home | Main Index | Thread Index | Old Index