--- MiNT/src/unifs.c 2018/04/24 17:58:11 1.1.1.5 +++ MiNT/src/unifs.c 2018/04/24 17:58:54 1.1.1.6 @@ -128,6 +128,8 @@ typedef struct unifile { struct unifile *next; + short cdate, ctime; + } UNIFILE; @@ -188,6 +190,10 @@ unifs_init() u->dev = i; + u->cdate = datestamp; + + u->ctime = timestamp; + if (i == PROCDRV) { strcpy(u->name, "proc"); @@ -352,7 +358,7 @@ do_ulookup(dir, name, fc, up) for (u = u_root; u; u = u->next) { - if (!stricmp(name, u->name)) { + if (!strnicmp(name, u->name, NAME_MAX)) { if ( (u->mode & S_IFMT) == S_IFDIR ) { @@ -438,7 +444,7 @@ uni_getxattr(fc, xattr) xattr->index = fc->index; - xattr->dev = fc->dev; + xattr->dev = xattr->rdev = fc->dev; xattr->nlink = 1; @@ -476,9 +482,9 @@ uni_getxattr(fc, xattr) } - xattr->mtime = xattr->atime = xattr->ctime = 0; + xattr->mtime = xattr->atime = xattr->ctime = u->ctime; - xattr->mdate = xattr->adate = xattr->cdate = 0; + xattr->mdate = xattr->adate = xattr->cdate = u->cdate; return 0; @@ -592,10 +598,14 @@ uni_remove(dir, name) while (u) { - if (!strncmp(u->name, name, NAME_MAX)) { + if (!strnicmp(u->name, name, NAME_MAX)) { if ( (u->mode & S_IFMT) != S_IFLNK ) return EFILNF; + if (curproc->euid && (u->dev != curproc->euid)) + + return EACCDN; + kfree(u->data); if (lastu) @@ -760,6 +770,14 @@ uni_getname(root, dir, pathname, size) + if (!fs) { + + *pathname = 0; + + return 0; + + } + if (!(fs->fsflags & FS_LONGPATH)) { r = (*fs->getname)(&curproc->root[dir->dev], dir, tmppath, PATH_MAX); @@ -814,7 +832,7 @@ uni_rename(olddir, oldname, newdir, newn for (u = u_root; u; u = u->next) { - if (!stricmp(u->name, oldname)) + if (!strnicmp(u->name, oldname, NAME_MAX)) break; @@ -1124,6 +1142,14 @@ uni_pathconf(dir, which) return DP_CASEINSENS; + case DP_MODEATTR: + + return DP_FT_DIR|DP_FT_LNK; + + case DP_XATTRFIELDS: + + return DP_INDEX|DP_DEV|DP_NLINK|DP_SIZE; + default: return EINVFN; @@ -1218,6 +1244,12 @@ uni_symlink(dir, name, to) + if (curproc->egid) + + return EACCDN; /* only members of admin group may do that */ + + + u = kmalloc(SIZEOF(UNIFILE)); if (!u) return EACCDN; @@ -1244,12 +1276,16 @@ uni_symlink(dir, name, to) u->mode = S_IFLNK | DEFAULT_DIRMODE; - u->dev = curproc->ruid; + u->dev = curproc->euid; u->next = u_root; u->fs = &uni_filesys; + u->cdate = datestamp; + + u->ctime = timestamp; + u_root = u; return 0; @@ -1382,7 +1418,7 @@ uni_fscntl(dir, name, cmd, arg) - if (cmd == FS_INSTALL) { /* install a new filesystem */ + if (cmd == (int)FS_INSTALL) { /* install a new filesystem */ struct fs_descr *d = (struct fs_descr*)arg; @@ -1404,7 +1440,7 @@ uni_fscntl(dir, name, cmd, arg) return (long)&kernelinfo; /* return pointer to kernel info as OK */ - } else if (cmd == FS_MOUNT) { /* install a new gemdos-only device for this FS */ + } else if (cmd == (int)FS_MOUNT) { /* install a new gemdos-only device for this FS */ struct fs_descr *d = (struct fs_descr*)arg; @@ -1466,7 +1502,7 @@ uni_fscntl(dir, name, cmd, arg) return (long)u->dev; - } else if (cmd == FS_UNMOUNT) { /* remove a file system's directory */ + } else if (cmd == (int)FS_UNMOUNT) { /* remove a file system's directory */ struct fs_descr *d = (struct fs_descr*)arg; @@ -1532,7 +1568,7 @@ uni_fscntl(dir, name, cmd, arg) return uni_remove(dir, name); - } else if (cmd == FS_UNINSTALL) { /* remove file system from kernel list */ + } else if (cmd == (int)FS_UNINSTALL) { /* remove file system from kernel list */ struct fs_descr *d = (struct fs_descr*)arg;