droyo / styx

Go library for the 9P filesystem protocol
MIT License
64 stars 18 forks source link

styx.Topen flags are 0 on write? #36

Open aep opened 1 year ago

aep commented 1 year ago

not sure if this is correct and i'm just confused?

case styx.Topen:                                        
    f, err := os.OpenFile(p, msg.Flag , 0777)              
    log.Println("Open", p, msg.Flag, err)      
    msg.Ropen(f, err)     

indicates Flag is always 0, so that when i do

./9pfuse localhost ~/mnt
echo bla > ~/mnt/bar

bar is just an empty file. presumably because it would require O_RDWR to actually write anything

aep commented 1 year ago

just appening O_RDWR if its not a dir works, but i'm not sure if this is correct


            case styx.Topen:

                s, err := os.Stat(p)
                if err != nil {
                    continue
                }

                var f *os.File
                if s.IsDir() {
                    f, err  = os.OpenFile(p, msg.Flag , 0777)
                } else {
                    f ,err  = os.OpenFile(p, msg.Flag | os.O_RDWR , 0777)
                }
                log.Println("Open file", p, msg.Flag, err)
                msg.Ropen(f, err)