droyo/styx

styx.Topen flags are 0 on write?

Opened this issue · 1 comments

aep commented

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

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)