Bug in disk/mkfs processing to a disk/kfs file system?

Skip to first unread message

Go Phone

Jul 24, 2021, 12:33:54 AM7/24/21
to inferno-os


disk/mkfs updates the mtime after creating a directory or file.

But, disk/kfs does not allow the mtime to be changed for a directory unless the mode in the Wstat message is the default value of ~0.

This is from the disk/kfs -D messages:
<- Tmsg.Wstat(1,163,Dir("","","joe",Qid(16rffffffffffffffff,1,16rff),8r20000000755,-1,1627005381,-1,16rffff,-1))
-> Rmsg.Error(1,"wstat -- attempt to change directory")

Is there a reason why disk/kfs does not allow stat changes to a directory whose mode is not the default value of ~0 (seeded by nulldir)?

This is the relevant code of disk/kfs.b that deals with this situation:
        # Before doing sanity checks, find out what the
        # new 'mode' should be:
        # if 'type' and 'mode' are both defaults, take the
        # new mode from the old directory entry;
        # else if 'type' is the default, use the new mode entry;
        # else if 'mode' is the default, create the new mode from
        # 'type' or'ed with the old directory mode;
        # else neither are defaults, use the new mode but check
        # it agrees with 'type'.

        if(dir.qid.qtype == 16rFF && dir.mode == ~0){
                dir.mode = d.mode & 8r777;
                if(d.mode & DLOCK)
                        dir.mode |= DMEXCL;
                if(d.mode & DAPND)
                        dir.mode |= DMAPPEND;
                if(d.mode & DDIR)
                        dir.mode |= DMDIR;
        else if(dir.qid.qtype == 16rFF){
                # nothing to do
        else if(dir.mode == ~0)
                dir.mode = (dir.qid.qtype<<24)|(d.mode & 8r777);
        else if(dir.qid.qtype != ((dir.mode>>24) & 16rFF)){
                return ferr(f, Eqidmode, file, p1);

        # Check for unknown type/mode bits
        # and an attempt to change the directory bit.

        if(dir.mode & ~(DMDIR|DMAPPEND|DMEXCL|8r777)){
                return ferr(f, Enotm, file, p1);
        if(d.mode & DDIR)
                mode := DMDIR;
                mode = 0;
        if((dir.mode^mode) & DMDIR){
                return ferr(f, Enotd, file, p1);


Reply all
Reply to author
0 new messages