level2: add hooks to allow level 2 platforms to provide their own path buffers
authorAlan Cox <alan@linux.intel.com>
Tue, 29 Dec 2015 23:30:23 +0000 (23:30 +0000)
committerAlan Cox <alan@linux.intel.com>
Tue, 29 Dec 2015 23:30:23 +0000 (23:30 +0000)
(If you go over 512 bytes the standard tmpbuf/brelse solution won't work, so
 for bigger systems malloc may be preferred)

Kernel/filesys.c
Kernel/include/kernel.h
Kernel/include/level2.h

index 51b9402..49f3b6b 100644 (file)
@@ -15,7 +15,7 @@ inoptr n_open(char *uname, inoptr *parent)
     inoptr r;
     char *tb;
 
-    tb = (char*)tmpbuf(); /* temporary memory to hold kernel's copy of the filename */
+    tb = (char*)pathbuf(); /* temporary memory to hold kernel's copy of the filename */
 
     if (ugets(uname, tb, 512) == -1) {
         udata.u_error = EFAULT;
@@ -29,7 +29,7 @@ inoptr n_open(char *uname, inoptr *parent)
 
     r = kn_open(tb, parent);
 
-    brelse(tb);
+    pathfree(tb);
 
     return r;
 }
index d70dc4f..7f51c89 100644 (file)
@@ -45,7 +45,8 @@ From UZI by Doug Braun and UZI280 by Stefan Nitschke.
 #define limit_exceeded(x,y) (0)
 #define can_signal(p, sig) \
        (udata.u_ptab->p_uid == (p)->p_uid || super())
-
+#define pathbuf()      tmpbuf()
+#define pathfree(tb)   brelse(tb)
 #endif
 
 #define CPM_EMULATOR_FILENAME    "/usr/cpm/emulator"
index 512c78a..e845e89 100644 (file)
@@ -27,6 +27,12 @@ extern void jobcontrol_in(struct tty *tty);
 extern void jobcontrol_out(struct tty *tty);
 extern int tcsetpgrp(struct tty *tty, char *data);
 
+/* Platform must implement according to its PATH_MAX and allocators. If
+   you are using a 512 byte path limit then calling tmpbuf() and brelse()
+   is sufficient */
+extern char *pathhbuf(void);
+extern void pathfree(char *p);
+
 /* The first half of this always gets used with a constant so using a macro
    turns the whole thing into a constant 32bit comparison with a fixed
    or global register memory address */