@@ -832,7 +832,7 @@ def fd_read(self, m: pywasm.core.Machine, args: typing.List[int]) -> typing.List
832832 elem_len = mems .get_u32 (iovs_ptr + 4 )
833833 data = [
834834 lambda : os .read (file .host_fd , elem_len ),
835- lambda : file .pipe .read (elem_len ),
835+ lambda : file .pipe .read (elem_len ) if file . pipe else b'' ,
836836 ][self .help_pipe (args [0 ])]()
837837 if len (data ) == 0 :
838838 break
@@ -965,7 +965,7 @@ def fd_write(self, m: pywasm.core.Machine, args: typing.List[int]) -> typing.Lis
965965 data .extend (elem )
966966 size = [
967967 lambda : os .write (file .host_fd , data ),
968- lambda : file .pipe .write (data ),
968+ lambda : file .pipe .write (data ) if file . pipe else 0 ,
969969 ][int (self .help_pipe (args [0 ]))]()
970970 mems .put_u32 (args [3 ], size )
971971 return [self .ERRNO_SUCCESS ]
@@ -1072,8 +1072,9 @@ def path_filestat_get(self, m: pywasm.core.Machine, args: typing.List[int]) -> t
10721072 name = mems .get (args [2 ], args [3 ]).decode ()
10731073 if self .help_escp (file .wasm_name , name ):
10741074 return [self .ERRNO_PERM ]
1075+ foll = flag & self .LOOKUPFLAGS_SYMLINK_FOLLOW != 0
10751076 try :
1076- info = os .stat (name , dir_fd = file .host_fd , follow_symlinks = flag & self . LOOKUPFLAGS_SYMLINK_FOLLOW )
1077+ info = os .stat (name , dir_fd = file .host_fd , follow_symlinks = foll )
10771078 except FileNotFoundError :
10781079 return [self .ERRNO_NOENT ]
10791080 mems .put_u64 (args [4 ], 1 )
@@ -1113,8 +1114,9 @@ def path_filestat_set_times(self, m: pywasm.core.Machine, args: typing.List[int]
11131114 mtim = args [5 ]
11141115 if args [6 ] & self .FSTFLAGS_MTIM_NOW :
11151116 mtim = time .time_ns ()
1117+ foll = flag & self .LOOKUPFLAGS_SYMLINK_FOLLOW != 0
11161118 try :
1117- os .utime (name , ns = (atim , mtim ), dir_fd = file .host_fd , follow_symlinks = flag & self . LOOKUPFLAGS_SYMLINK_FOLLOW )
1119+ os .utime (name , ns = (atim , mtim ), dir_fd = file .host_fd , follow_symlinks = foll )
11181120 except FileNotFoundError :
11191121 return [self .ERRNO_NOENT ]
11201122 return [self .ERRNO_SUCCESS ]
@@ -1136,7 +1138,7 @@ def path_link(self, m: pywasm.core.Machine, args: typing.List[int]) -> typing.Li
11361138 return [self .ERRNO_PERM ]
11371139 if self .help_escp (dest .wasm_name , dest_name ):
11381140 return [self .ERRNO_PERM ]
1139- foll = args [1 ] & self .LOOKUPFLAGS_SYMLINK_FOLLOW
1141+ foll = args [1 ] & self .LOOKUPFLAGS_SYMLINK_FOLLOW != 0
11401142 try :
11411143 os .link (stem_name , dest_name , src_dir_fd = stem .host_fd , dst_dir_fd = dest .host_fd , follow_symlinks = foll )
11421144 except FileExistsError :
@@ -1489,6 +1491,7 @@ def sock_accept(self, m: pywasm.core.Machine, args: typing.List[int]) -> typing.
14891491 wasm_fd = len (self .fd )
14901492 self .fd .append (self .File (
14911493 host_fd = host_fd ,
1494+ host_flag = 0 ,
14921495 host_name = file .host_name ,
14931496 host_status = self .FILE_STATUS_OPENED ,
14941497 pipe = None ,
0 commit comments