From: Alan Cox Date: Tue, 29 Dec 2015 23:30:23 +0000 (+0000) Subject: level2: add hooks to allow level 2 platforms to provide their own path buffers X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=830fec71bf448708145ef82406c08ce99a95e557;p=FUZIX.git level2: add hooks to allow level 2 platforms to provide their own path buffers (If you go over 512 bytes the standard tmpbuf/brelse solution won't work, so for bigger systems malloc may be preferred) --- diff --git a/Kernel/filesys.c b/Kernel/filesys.c index 51b94021..49f3b6bb 100644 --- a/Kernel/filesys.c +++ b/Kernel/filesys.c @@ -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; } diff --git a/Kernel/include/kernel.h b/Kernel/include/kernel.h index d70dc4f3..7f51c894 100644 --- a/Kernel/include/kernel.h +++ b/Kernel/include/kernel.h @@ -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" diff --git a/Kernel/include/level2.h b/Kernel/include/level2.h index 512c78ae..e845e898 100644 --- a/Kernel/include/level2.h +++ b/Kernel/include/level2.h @@ -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 */