Author: kib
Date: Fri Dec 11 00:37:51 2020
New Revision: 368540
URL: https://svnweb.freebsd.org/changeset/base/368540

Log:
  MFC r368343:
  Fix compat32 for ntp_adjtime(2).

Modified:
  stable/12/sys/compat/freebsd32/freebsd32.h
  stable/12/sys/compat/freebsd32/freebsd32_misc.c
  stable/12/sys/compat/freebsd32/syscalls.master
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/freebsd32/freebsd32.h
==============================================================================
--- stable/12/sys/compat/freebsd32/freebsd32.h  Fri Dec 11 00:35:04 2020        
(r368539)
+++ stable/12/sys/compat/freebsd32/freebsd32.h  Fri Dec 11 00:37:51 2020        
(r368540)
@@ -388,4 +388,24 @@ struct procctl_reaper_pids32 {
        uint32_t rp_pids;
 };
 
+struct timex32 {
+       unsigned int modes;
+       int32_t offset;
+       int32_t freq;
+       int32_t maxerror;
+       int32_t esterror;
+       int     status;
+       int32_t constant;
+       int32_t precision;
+       int32_t tolerance;
+       int32_t ppsfreq;
+       int32_t jitter;
+       int     shift;
+       int32_t stabil;
+       int32_t jitcnt;
+       int32_t calcnt;
+       int32_t errcnt;
+       int32_t stbcnt;
+};
+
 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */

Modified: stable/12/sys/compat/freebsd32/freebsd32_misc.c
==============================================================================
--- stable/12/sys/compat/freebsd32/freebsd32_misc.c     Fri Dec 11 00:35:04 
2020        (r368539)
+++ stable/12/sys/compat/freebsd32/freebsd32_misc.c     Fri Dec 11 00:37:51 
2020        (r368540)
@@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sysproto.h>
 #include <sys/systm.h>
 #include <sys/thr.h>
+#include <sys/timex.h>
 #include <sys/unistd.h>
 #include <sys/ucontext.h>
 #include <sys/vnode.h>
@@ -3540,6 +3541,71 @@ freebsd32_sched_rr_get_interval(struct thread *td,
                CP(ts, ts32, tv_sec);
                CP(ts, ts32, tv_nsec);
                error = copyout(&ts32, uap->interval, sizeof(ts32));
+       }
+       return (error);
+}
+
+static void
+timex_to_32(struct timex32 *dst, struct timex *src)
+{
+       CP(*src, *dst, modes);
+       CP(*src, *dst, offset);
+       CP(*src, *dst, freq);
+       CP(*src, *dst, maxerror);
+       CP(*src, *dst, esterror);
+       CP(*src, *dst, status);
+       CP(*src, *dst, constant);
+       CP(*src, *dst, precision);
+       CP(*src, *dst, tolerance);
+       CP(*src, *dst, ppsfreq);
+       CP(*src, *dst, jitter);
+       CP(*src, *dst, shift);
+       CP(*src, *dst, stabil);
+       CP(*src, *dst, jitcnt);
+       CP(*src, *dst, calcnt);
+       CP(*src, *dst, errcnt);
+       CP(*src, *dst, stbcnt);
+}
+
+static void
+timex_from_32(struct timex *dst, struct timex32 *src)
+{
+       CP(*src, *dst, modes);
+       CP(*src, *dst, offset);
+       CP(*src, *dst, freq);
+       CP(*src, *dst, maxerror);
+       CP(*src, *dst, esterror);
+       CP(*src, *dst, status);
+       CP(*src, *dst, constant);
+       CP(*src, *dst, precision);
+       CP(*src, *dst, tolerance);
+       CP(*src, *dst, ppsfreq);
+       CP(*src, *dst, jitter);
+       CP(*src, *dst, shift);
+       CP(*src, *dst, stabil);
+       CP(*src, *dst, jitcnt);
+       CP(*src, *dst, calcnt);
+       CP(*src, *dst, errcnt);
+       CP(*src, *dst, stbcnt);
+}
+
+int
+freebsd32_ntp_adjtime(struct thread *td, struct freebsd32_ntp_adjtime_args 
*uap)
+{
+       struct timex tx;
+       struct timex32 tx32;
+       int error, retval;
+
+       error = copyin(uap->tp, &tx32, sizeof(tx32));
+       if (error == 0) {
+               timex_from_32(&tx, &tx32);
+               error = kern_ntp_adjtime(td, &tx, &retval);
+               if (error == 0) {
+                       timex_to_32(&tx32, &tx);
+                       error = copyout(&tx32, uap->tp, sizeof(tx32));
+                       if (error == 0)
+                               td->td_retval[0] = retval;
+               }
        }
        return (error);
 }

Modified: stable/12/sys/compat/freebsd32/syscalls.master
==============================================================================
--- stable/12/sys/compat/freebsd32/syscalls.master      Fri Dec 11 00:35:04 
2020        (r368539)
+++ stable/12/sys/compat/freebsd32/syscalls.master      Fri Dec 11 00:37:51 
2020        (r368540)
@@ -333,7 +333,8 @@
                                    const void *buf, size_t nbyte, int pad, \
                                    uint32_t offset1, uint32_t offset2); }
 175    AUE_NULL        UNIMPL  nosys
-176    AUE_NTP_ADJTIME NOPROTO { int ntp_adjtime(struct timex *tp); }
+176    AUE_NTP_ADJTIME STD     { int freebsd32_ntp_adjtime( \
+                                   struct timex32 *tp); }
 177    AUE_NULL        UNIMPL  sfork (BSD/OS 2.x)
 178    AUE_NULL        UNIMPL  getdescriptor (BSD/OS 2.x)
 179    AUE_NULL        UNIMPL  setdescriptor (BSD/OS 2.x)
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to