# HG changeset patch # User menikon # Date 1580891957 -32400 # Node ID 66a6aedf60f9bd6112aa706efc5a74411427ed48 # Parent eb62acc627f1ff02c9b9321e87c105a402e31b1d add CodeGear dirlink_loopcheck etc diff -r eb62acc627f1 -r 66a6aedf60f9 src/impl/fs_impl.cbc --- a/src/impl/fs_impl.cbc Wed Feb 05 16:48:45 2020 +0900 +++ b/src/impl/fs_impl.cbc Wed Feb 05 17:39:17 2020 +0900 @@ -182,9 +182,12 @@ goto dirlookup_loopcheck(fs, dp, name, off, poff, de, next(...)); } -__code dirlinkfs_impl(struct fs_impl* fs, struct inode* dp, char* name, uint inum, __code next(...)) { - - goto next(...); +__code dirlinkfs_impl(struct fs_impl* fs, struct inode* ip, struct dirent* de, struct inode* dp, char* name, uint off, uint inum, __code next(...)) { //:skip + // Check that name is not present. + if ((ip = dirlookup(dp, name, 0)) != 0) { + goto dirlink_namecheck(fs, ip, next(...)); + } + goto dirlink_loopcheck(fs, de, dp, off, next(...)); } static struct inode* iget (uint dev, uint inum) diff -r eb62acc627f1 -r 66a6aedf60f9 src/impl/fs_impl.h --- a/src/impl/fs_impl.h Wed Feb 05 16:48:45 2020 +0900 +++ b/src/impl/fs_impl.h Wed Feb 05 17:39:17 2020 +0900 @@ -25,5 +25,6 @@ __code dirlookup_loopcheck(Type* fs_impl, struct inode* dp, char* name, uint off, uint* poff, dirent* de, next(...)); __code dirlookup_loop(struct fs_impl* fs_impl, struct inode* dp, char* name, uint off, uint* poff, dirent* de, __code next(...)); __code dirlookup_noloop(struct fs_impl* fs_impl, __code next(int ret, ...)); + __code dirlink_namecheck(struct fs_impl* fs_impl, struct inode* ip, __code next(int ret, ...)); __code next(...); } fs_impl; diff -r eb62acc627f1 -r 66a6aedf60f9 src/impl/fs_impl_private.cbc --- a/src/impl/fs_impl_private.cbc Wed Feb 05 16:48:45 2020 +0900 +++ b/src/impl/fs_impl_private.cbc Wed Feb 05 17:39:17 2020 +0900 @@ -275,3 +275,13 @@ ret = 0; goto next(ret, ...); } + +__code dirlink_namecheck(struct fs_impl* fs_impl, struct inode* ip, __code next(int ret, ...)){ + iput(ip); + ret = -1; + goto next(ret, ...); +} + +__code dirlink_loopcheck(struct fs_impl* fs_impl, struct dirent* de, struct inode* dp, uint off, __code next(...)){ //:skip + +} diff -r eb62acc627f1 -r 66a6aedf60f9 src/interface/fs.dg --- a/src/interface/fs.dg Wed Feb 05 16:48:45 2020 +0900 +++ b/src/interface/fs.dg Wed Feb 05 17:39:17 2020 +0900 @@ -35,7 +35,7 @@ __code writei(Impl* fs, struct inode* ip, char* src, uint off, uint n, __code next(...)); __code namecmp(Impl* fs, const char* s, const char* t, __code next(int strncmp_val, ...)); __code dirlookup(struct inode* dp, char* name, uint* poff, dirent* de, __code next(int ret, ...)); - __code dirlink(Impl* fs, struct inode* dp, char* name, uint inum, __code next(...)); + __code dirlink(struct fs_impl* fs, struct inode* ip, struct dirent* de, struct inode* dp, char* name, uint off, uint inum, __code next(...)); __code namei(Impl* fs, char* path, __code next(int namex_val, ...)); __code nameiparent(Impl* fs, char* path, char* name, __code next(int namex_val, ...)); __code next(...);