From 3a52b3d74bac0a0f85f544b402e80f821550c262 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Wed, 23 Mar 2016 09:57:20 +1000 Subject: [PATCH] I've got mkdir working in the alt system. I had to allow the dir bit in the permissions mask in creat, through. --- build/Makefile | 6 ++- build/alt/proto | 1 + src/alt/s2.s | 4 +- src/alt/wktmkdir.s | 107 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/alt/wktmkdir.s diff --git a/build/Makefile b/build/Makefile index 9c6388b..bfcf26a 100644 --- a/build/Makefile +++ b/build/Makefile @@ -85,7 +85,7 @@ cmd: dirs $(BINDIR)/as $(BINDIR)/cat $(BINDIR)/check $(BINDIR)/chmod \ # Alternate commands: no dd, but . and .. altcmd: dirs $(BINDIR)/as $(BINDIR)/cat $(BINDIR)/check $(BINDIR)/chmod \ $(BINDIR)/chown $(BINDIR)/altchrm $(BINDIR)/cp $(BINDIR)/ds \ - $(BINDIR)/ed $(BINDIR)/altinit + $(BINDIR)/ed $(BINDIR)/altinit $(BINDIR)/altmkdir $(BINDIR)/as: $(CMDSRC)/as.s $(AS) $(ASARGS) -o $(BINDIR)/as $(CMDSRC)/as.s @@ -130,6 +130,10 @@ $(BINDIR)/init: $(CMDSRC)/init.s $(BINDIR)/altinit: $(ALTSRC)/init.s $(AS) $(ASARGS) -o $(BINDIR)/altinit $(ALTSRC)/init.s +$(BINDIR)/altmkdir: $(ALTSRC)/wktmkdir.s + $(AS) $(ASARGS) -o $(BINDIR)/altmkdir $(ALTSRC)/wktmkdir.s + + # The commands that did not come from the scans others: dirs $(BINDIR)/sh $(BINDIR)/wktcat $(BINDIR)/wktcp $(BINDIR)/date \ $(BINDIR)/ln $(BINDIR)/ls $(BINDIR)/mv $(BINDIR)/stat diff --git a/build/alt/proto b/build/alt/proto index 38e8733..fafdbca 100644 --- a/build/alt/proto +++ b/build/alt/proto @@ -33,6 +33,7 @@ init frwr- -1 bin/altinit ln frwr- -1 bin/ln ls frwr- -1 bin/altls + mkdir frwr- -1 bin/altmkdir mv frwr- -1 bin/mv password frw-- -1 fs/password sh frwr- -1 bin/sh diff --git a/src/alt/s2.s b/src/alt/s2.s index 9c1f70d..49a6dab 100644 --- a/src/alt/s2.s +++ b/src/alt/s2.s @@ -257,13 +257,15 @@ 1: jms access " here if not found lac u.ac " get access bits from user AC (zero for lock!) - and o17 " mask to permissions + and o37 " mask the permissions, but allow the dir bit jms icreat open1: " common exit for open/creat jms fassign " assign fd slot jms error " none free, return -1 jmp sysexit +o37: 037 " drwrw bitmask + "** 01-s1.pdf page 11 .close: jms finac " get fnode (open file) for fd in user AC diff --git a/src/alt/wktmkdir.s b/src/alt/wktmkdir.s new file mode 100644 index 0000000..eed3ed6 --- /dev/null +++ b/src/alt/wktmkdir.s @@ -0,0 +1,107 @@ +" Warren's alternative mkdir command: mkdir newdir + +main: + lac 017777 i " Do we have any arguments? + sad d4 + jmp noarg + + lac 017777 " Move five words past the argument word count + tad d5 " so that AC points at the first argument + dac 017777 + dac 6f " Save this as the argument name in + dac 7f " several system calls + dac 8f + dac 9f + + " Get the status of the argument so that we can + " see if it exists. Apparently creat (below) works + " on an existing file + lac statbufptr + sys status; 6:0 + sna + jmp badfile + + " Try to create a new file but with the isdir bit set + lac o34 + sys creat; 7:0 + spa + jmp badfile + dac fd + + " Get the status of the current directory so that we can + " get its i-num + lac statbufptr + sys status; dot + + " Write a dummy entry into the new directory that is + " equivalent to .., just so we can refer to the parent + lac fd + sys write; s.inum; 8 + + " Move into the new directory + sys chdir; 8:0 + + " Create a . link to us + sys link; up; 9:0; dot + + " Create a .. link to the parent + sys link; up; dot; dotdot + + " Try to make a system link; this may fail + sys link; up; system; system + + " Now zero the i-num of the dummy entry + lac fd + sys seek; 0; 0 + lac fd + sys write; zero; 1 + + " Close the file and exit + lac fd + sys close + sys exit + +noarg: + " Print a "no arg" error and exit + lac d1 + sys write; noargstr; 4 + sys exit +noargstr: ; < a>; ; 012 + +badfile: + lac lac 017777 " Get the pointer to the new dirname + dac 1f " Store it in 1f below + lac d1 + sys write; 1:0; 4 " Write the name, max 4 words + lac d1 " Then write " ?\n" + sys write; 1f; 2 + sys exit " and exit +1: 040; 077012 " String literal: " ?\n" + +fd: 0 " File descriptor of the new directory +zero: 0 +d1: 1 +d4: 4 +d5: 5 +o34: 034 " drw-- permission bits + +statbufptr: statbuf " Pointer to the statbuf +statbuf: " Status buffer fields below +s.perm: 0 +s.blk1: 0 +s.blk2: 0 +s.blk3: 0 +s.blk4: 0 +s.blk5: 0 +s.blk6: 0 +s.blk7: 0 +s.uid: 0 +s.nlinks: 0 +s.size: 0 +s.uniq: 0 +s.inum: 0 +up: ; 040040; 040040; 040040 +pad: 0; 0; 0 +dotdot: <..>; 040040; 040040; 040040 +dot: 056040; 040040; 040040; 040040 +system: ; ; ; 040040