add einval for invalid operations
[unix-history] / usr / src / sys / kern / subr_xxx.c
index 7137d22..c6813db 100644 (file)
-/*     subr_xxx.c      4.22    83/05/27        */
-
-#include "../machine/pte.h"
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/conf.h"
-#include "../h/inode.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-#include "../h/proc.h"
-#include "../h/fs.h"
-#include "../h/vm.h"
-#include "../h/cmap.h"
-#include "../h/uio.h"
-
 /*
 /*
- * Routine placed in illegal entries in the bdevsw and cdevsw tables.
+ * Copyright (c) 1982, 1986, 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)subr_xxx.c  8.3 (Berkeley) %G%
  */
  */
-nodev()
-{
-
-       return (ENODEV);
-}
 
 /*
 
 /*
- * Null routine; placed in insignificant entries
- * in the bdevsw and cdevsw tables.
+ * Miscellaneous trivial functions, including many
+ * that are often inline-expanded or done in assembler.
  */
  */
-nulldev()
-{
+#include <sys/param.h>
+#include <sys/systm.h>
 
 
-       return (0);
-}
+#include <machine/cpu.h>
 
 
-imin(a, b)
-{
-
-       return (a < b ? a : b);
-}
-
-imax(a, b)
+/*
+ * Unsupported device function (e.g. writing to read-only device).
+ */
+int
+enodev()
 {
 
 {
 
-       return (a > b ? a : b);
+       return (ENODEV);
 }
 
 }
 
-unsigned
-min(a, b)
-       u_int a, b;
+/*
+ * Unconfigured device function; driver not configured.
+ */
+int
+enxio()
 {
 
 {
 
-       return (a < b ? a : b);
+       return (ENXIO);
 }
 
 }
 
-unsigned
-max(a, b)
-       u_int a, b;
+/*
+ * Unsupported ioctl function.
+ */
+int
+enoioctl()
 {
 
 {
 
-       return (a > b ? a : b);
+       return (ENOTTY);
 }
 
 }
 
-extern cabase, calimit;
-extern struct pte camap[];
-
-caddr_t        cacur = (caddr_t)&cabase;
-caddr_t        camax = (caddr_t)&cabase;
-int    cax = 0;
 /*
 /*
- * This is a kernel-mode storage allocator.
- * It is very primitive, currently, in that
- * there is no way to give space back.
- * It serves, for the time being, the needs of
- * auto-configuration code and the like which
- * need to allocate some stuff at boot time.
+ * Unsupported system function.
+ * This is used for an otherwise-reasonable operation
+ * that is not supported by the current system binary.
  */
  */
-caddr_t
-calloc(size)
-       int size;
-{
-       register caddr_t res;
-       register int i;
-
-       if (cacur+size >= (caddr_t)&calimit)
-               panic("calloc");
-       while (cacur+size > camax) {
-               (void) vmemall(&camap[cax], CLSIZE, &proc[0], CSYS);
-               vmaccess(&camap[cax], camax, CLSIZE);
-               for (i = 0; i < CLSIZE; i++)
-                       clearseg(camap[cax++].pg_pfnum);
-               camax += NBPG * CLSIZE;
-       }
-       res = cacur;
-       cacur += size;
-       return (res);
-}
-
-#ifndef vax
-ffs(mask)
-       register long mask;
+int
+enosys()
 {
 {
-       register int i;
 
 
-       for(i = 1; i < NSIG; i++) {
-               if (mask & 1)
-                       return (i);
-               mask >>= 1;
-       }
-       return (0);
+       return (ENOSYS);
 }
 
 }
 
-bcmp(s1, s2, len)
-       register char *s1, *s2;
-       register int len;
+/*
+ * Return error for operation not supported
+ * on a specific object or file type.
+ */
+int
+eopnotsupp()
 {
 
 {
 
-       while (len--)
-               if (*s1++ != *s2++)
-                       return (1);
-       return (0);
+       return (EOPNOTSUPP);
 }
 
 }
 
-strlen(s1)
-       register char *s1;
+/*
+ * Return error for an inval operation
+ * on a specific object or file type.
+ */
+int
+einval()
 {
 {
-       register int len;
 
 
-       for (len = 0; *s1++ != '\0'; len++)
-               /* void */;
-       return (len);
+       return (EINVAL);
 }
 }
-#endif
 
 /*
 
 /*
- * Pass back c to the user.
+ * Generic null operation, always returns success.
  */
  */
-passuc(c, uio)
-       register c;
-       struct uio *uio;
+int
+nullop()
 {
 {
-       register struct iovec *iov = uio->uio_iov;
-
-       switch (uio->uio_segflg) {
-
-       case 0:
-               if (subyte(iov->iov_base, c) < 0)
-                       goto fault;
-               break;
-
-       case 1:
-               *iov->iov_base = c;
-               break;
-
-       case 2:
-               if (suibyte(iov->iov_base, c) < 0)
-                       goto fault;
-               break;
-       }
-       iov->iov_base++;
-       iov->iov_len--;
-       uio->uio_resid--;
-       uio->uio_offset++;
-       if (iov->iov_len <= 0) {
-               uio->uio_iov++;
-               uio->uio_iovcnt--;
-       }
+
        return (0);
        return (0);
-fault:
-       return (EFAULT);
 }
 }