From f53494c28e362fb7752bbc83417b9ba47cff0bf5 Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 3 Sep 2008 04:50:04 +0000 Subject: DO NOT MAIL: xv6 web pages --- web/xv6-names.html | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 web/xv6-names.html (limited to 'web/xv6-names.html') diff --git a/web/xv6-names.html b/web/xv6-names.html new file mode 100644 index 0000000..926be3a --- /dev/null +++ b/web/xv6-names.html @@ -0,0 +1,78 @@ + + +Homework: Naming + + + +

Homework: Naming

+ +

+Read: namei in fs.c, fd.c, sysfile.c + +

+This homework should be turned in at the beginning of lecture. + +

+Symbolic Links + +

+As you read namei and explore its varied uses throughout xv6, +think about what steps would be required to add symbolic links +to xv6. +A symbolic link is simply a file with a special type (e.g., T_SYMLINK +instead of T_FILE or T_DIR) whose contents contain the path being +linked to. + +

+Turn in a short writeup of how you would change xv6 to support +symlinks. List the functions that would have to be added or changed, +with short descriptions of the new functionality or changes. + +

+This completes the homework. + +

+The following is not required. If you want to try implementing +symbolic links in xv6, here are the files that the course staff +had to change to implement them: + +

+fs.c: 20 lines added, 4 modified
+syscall.c: 2 lines added
+syscall.h: 1 line added
+sysfile.c: 15 lines added
+user.h: 1 line added
+usys.S: 1 line added
+
+ +Also, here is an ln program: + +
+#include "types.h"
+#include "user.h"
+
+int
+main(int argc, char *argv[])
+{
+  int (*ln)(char*, char*);
+  
+  ln = link;
+  if(argc > 1 && strcmp(argv[1], "-s") == 0){
+    ln = symlink;
+    argc--;
+    argv++;
+  }
+  
+  if(argc != 3){
+    printf(2, "usage: ln [-s] old new (%d)\n", argc);
+    exit();
+  }
+  if(ln(argv[1], argv[2]) < 0){
+    printf(2, "%s failed\n", ln == symlink ? "symlink" : "link");
+    exit();
+  }
+  exit();
+}
+
+ + -- cgit v1.2.3