changeset 254:66a6aedf60f9

add CodeGear dirlink_loopcheck etc
author menikon
date Wed, 05 Feb 2020 17:39:17 +0900
parents eb62acc627f1
children 8c8f092e4f52
files src/impl/fs_impl.cbc src/impl/fs_impl.h src/impl/fs_impl_private.cbc src/interface/fs.dg
diffstat 4 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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;
--- 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
+
+}
--- 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(...);