--- MiNT/src/unifs.c 2018/04/24 17:55:36 1.1 +++ MiNT/src/unifs.c 2018/04/24 17:55:54 1.1.1.2 @@ -20,45 +20,45 @@ extern FILESYS bios_filesys, proc_filesy -static long uni_root P_((int drv, fcookie *fc)); +static long ARGS_ON_STACK uni_root P_((int drv, fcookie *fc)); -static long uni_lookup P_((fcookie *dir, const char *name, fcookie *fc)); +static long ARGS_ON_STACK uni_lookup P_((fcookie *dir, const char *name, fcookie *fc)); -static long uni_getxattr P_((fcookie *fc, XATTR *xattr)); +static long ARGS_ON_STACK uni_getxattr P_((fcookie *fc, XATTR *xattr)); -static long uni_chattr P_((fcookie *fc, int attrib)); +static long ARGS_ON_STACK uni_chattr P_((fcookie *fc, int attrib)); -static long uni_chown P_((fcookie *fc, int uid, int gid)); +static long ARGS_ON_STACK uni_chown P_((fcookie *fc, int uid, int gid)); -static long uni_chmode P_((fcookie *fc, unsigned mode)); +static long ARGS_ON_STACK uni_chmode P_((fcookie *fc, unsigned mode)); -static long uni_rmdir P_((fcookie *dir, const char *name)); +static long ARGS_ON_STACK uni_rmdir P_((fcookie *dir, const char *name)); -static long uni_remove P_((fcookie *dir, const char *name)); +static long ARGS_ON_STACK uni_remove P_((fcookie *dir, const char *name)); -static long uni_getname P_((fcookie *root, fcookie *dir, char *pathname)); +static long ARGS_ON_STACK uni_getname P_((fcookie *root, fcookie *dir, char *pathname)); -static long uni_rename P_((fcookie *olddir, char *oldname, +static long ARGS_ON_STACK uni_rename P_((fcookie *olddir, char *oldname, fcookie *newdir, const char *newname)); -static long uni_opendir P_((DIR *dirh, int flags)); +static long ARGS_ON_STACK uni_opendir P_((DIR *dirh, int flags)); -static long uni_readdir P_((DIR *dirh, char *nm, int nmlen, fcookie *)); +static long ARGS_ON_STACK uni_readdir P_((DIR *dirh, char *nm, int nmlen, fcookie *)); -static long uni_rewinddir P_((DIR *dirh)); +static long ARGS_ON_STACK uni_rewinddir P_((DIR *dirh)); -static long uni_closedir P_((DIR *dirh)); +static long ARGS_ON_STACK uni_closedir P_((DIR *dirh)); -static long uni_pathconf P_((fcookie *dir, int which)); +static long ARGS_ON_STACK uni_pathconf P_((fcookie *dir, int which)); -static long uni_dfree P_((fcookie *dir, long *buf)); +static long ARGS_ON_STACK uni_dfree P_((fcookie *dir, long *buf)); -static DEVDRV * uni_getdev P_((fcookie *fc, long *devsp)); +static DEVDRV * ARGS_ON_STACK uni_getdev P_((fcookie *fc, long *devsp)); -static long uni_symlink P_((fcookie *dir, const char *name, const char *to)); +static long ARGS_ON_STACK uni_symlink P_((fcookie *dir, const char *name, const char *to)); -static long uni_readlink P_((fcookie *fc, char *buf, int buflen)); +static long ARGS_ON_STACK uni_readlink P_((fcookie *fc, char *buf, int buflen)); @@ -110,7 +110,7 @@ typedef struct unifile { char name[NAME_MAX+1]; - short mode; + ushort mode; ushort dev; @@ -124,11 +124,7 @@ typedef struct unifile { -/* the "+1" is for shared memory, which has no BIOS drive */ - -#define UNI_DIRS NUM_DRIVES+1 - -static UNIFILE u_drvs[UNI_DIRS]; +static UNIFILE u_drvs[UNI_NUM_DRVS]; static UNIFILE *u_root = 0; @@ -148,7 +144,7 @@ unifs_init() u_root = u; - for (i = 0; i < NUM_DRIVES; i++,u++) { + for (i = 0; i < UNI_NUM_DRVS; i++,u++) { u->next = u+1; @@ -156,49 +152,55 @@ unifs_init() u->dev = i; - u->fs = 0; - - if (i == PROCDRV) + if (i == PROCDRV) { strcpy(u->name, "proc"); - else if (i == PIPEDRV) + u->fs = &proc_filesys; + + } else if (i == PIPEDRV) { strcpy(u->name, "pipe"); - else if (i == BIOSDRV) + u->fs = &pipe_filesys; + + } else if (i == BIOSDRV) { strcpy(u->name, "dev"); - else if (i == UNIDRV) { + u->fs = &bios_filesys; + + } else if (i == UNIDRV) { (u-1)->next = u->next; /* skip this drive */ + } else if (i == SHMDRV) { + + strcpy(u->name, "shm"); + + u->fs = &shm_filesys; + } else { u->name[0] = i + 'a'; u->name[1] = 0; + u->fs = 0; + } } - u->next = 0; - - u->mode = S_IFDIR|DEFAULT_DIRMODE; - - u->dev = SHMDEVICE; - - u->fs = &shm_filesys; + --u; /* oops, we went too far */ - strcpy(u->name, "shm"); + u->next = 0; } -static long +static long ARGS_ON_STACK uni_root(drv, fc) @@ -228,7 +230,7 @@ uni_root(drv, fc) -static long +static long ARGS_ON_STACK uni_lookup(dir, name, fc) @@ -250,13 +252,13 @@ uni_lookup(dir, name, fc) - TRACE("uni_lookup(%s)", name); + TRACE(("uni_lookup(%s)", name)); if (dir->index != 0) { - DEBUG("uni_lookup: bad directory"); + DEBUG(("uni_lookup: bad directory")); return EPTHNF; @@ -332,7 +334,7 @@ uni_lookup(dir, name, fc) } - DEBUG("uni_lookup: name (%s) not found", name); + DEBUG(("uni_lookup: name (%s) not found", name)); return EFILNF; @@ -340,7 +342,7 @@ uni_lookup(dir, name, fc) -static long +static long ARGS_ON_STACK uni_getxattr(fc, xattr) @@ -414,7 +416,7 @@ uni_getxattr(fc, xattr) -static long +static long ARGS_ON_STACK uni_chattr(dir, attrib) @@ -424,13 +426,15 @@ uni_chattr(dir, attrib) { + UNUSED(dir); UNUSED(attrib); + return EACCDN; } -static long +static long ARGS_ON_STACK uni_chown(dir, uid, gid) @@ -440,13 +444,17 @@ uni_chown(dir, uid, gid) { + UNUSED(dir); UNUSED(uid); + + UNUSED(gid); + return EINVFN; } -static long +static long ARGS_ON_STACK uni_chmode(dir, mode) @@ -456,13 +464,17 @@ uni_chmode(dir, mode) { + UNUSED(dir); + + UNUSED(mode); + return EINVFN; } -static long +static long ARGS_ON_STACK uni_rmdir(dir, name) @@ -486,7 +498,7 @@ uni_rmdir(dir, name) -static long +static long ARGS_ON_STACK uni_remove(dir, name) @@ -500,6 +512,10 @@ uni_remove(dir, name) + UNUSED(dir); + + + lastu = 0; u = u_root; @@ -538,7 +554,7 @@ uni_remove(dir, name) -static long +static long ARGS_ON_STACK uni_getname(root, dir, pathname) @@ -556,6 +572,10 @@ uni_getname(root, dir, pathname) + UNUSED(root); + + + fs = dir->fs; if (dir->dev == UNIDRV) { @@ -604,7 +624,7 @@ uni_getname(root, dir, pathname) } else { - *pathname++ = 0; + *pathname = 0; return EINTRN; @@ -630,7 +650,7 @@ uni_getname(root, dir, pathname) -static long +static long ARGS_ON_STACK uni_rename(olddir, oldname, newdir, newname) @@ -644,7 +664,7 @@ uni_rename(olddir, oldname, newdir, newn { - UNIFILE *u = 0; + UNIFILE *u; fcookie fc; @@ -652,6 +672,10 @@ uni_rename(olddir, oldname, newdir, newn + UNUSED(olddir); + + + for (u = u_root; u; u = u->next) { if (!stricmp(u->name, oldname)) @@ -664,7 +688,7 @@ uni_rename(olddir, oldname, newdir, newn if (!u) { - DEBUG("uni_rename: old file not found"); + DEBUG(("uni_rename: old file not found")); return EFILNF; @@ -678,7 +702,7 @@ uni_rename(olddir, oldname, newdir, newn if (r != EFILNF) { - DEBUG("uni_rename: error %ld", r); + DEBUG(("uni_rename: error %ld", r)); return (r == 0) ? EACCDN : r; @@ -694,7 +718,7 @@ uni_rename(olddir, oldname, newdir, newn -static long +static long ARGS_ON_STACK uni_opendir(dirh, flags) @@ -704,9 +728,13 @@ uni_opendir(dirh, flags) { + UNUSED(flags); + + + if (dirh->fc.index != 0) { - DEBUG("uni_opendir: bad directory"); + DEBUG(("uni_opendir: bad directory")); return EPTHNF; @@ -722,7 +750,7 @@ uni_opendir(dirh, flags) -static long +static long ARGS_ON_STACK uni_readdir(dirh, name, namelen, fc) @@ -842,7 +870,7 @@ tryagain: if (giveindex) { - namelen -= sizeof(long); + namelen -= (int)sizeof(long); if (namelen <= 0) return ERANGE; @@ -864,7 +892,7 @@ tryagain: -static long +static long ARGS_ON_STACK uni_rewinddir(dirh) @@ -880,7 +908,7 @@ uni_rewinddir(dirh) -static long +static long ARGS_ON_STACK uni_closedir(dirh) @@ -888,13 +916,15 @@ uni_closedir(dirh) { + UNUSED(dirh); + return 0; } -static long +static long ARGS_ON_STACK uni_pathconf(dir, which) @@ -904,6 +934,10 @@ uni_pathconf(dir, which) { + UNUSED(dir); + + + switch(which) { case -1: @@ -948,7 +982,7 @@ uni_pathconf(dir, which) -static long +static long ARGS_ON_STACK uni_dfree(dir, buf) @@ -958,6 +992,10 @@ uni_dfree(dir, buf) { + UNUSED(dir); + + + buf[0] = 0; /* number of free clusters */ buf[1] = 0; /* total number of clusters */ @@ -972,7 +1010,7 @@ uni_dfree(dir, buf) -static DEVDRV * +static DEVDRV * ARGS_ON_STACK uni_getdev(fc, devsp) @@ -982,6 +1020,10 @@ uni_getdev(fc, devsp) { + UNUSED(fc); + + + *devsp = EACCDN; return 0; @@ -990,7 +1032,7 @@ uni_getdev(fc, devsp) -static long +static long ARGS_ON_STACK uni_symlink(dir, name, to) @@ -1058,7 +1100,7 @@ uni_symlink(dir, name, to) -static long +static long ARGS_ON_STACK uni_readlink(fc, buf, buflen)