File tree Expand file tree Collapse file tree 1 file changed +26
-13
lines changed Expand file tree Collapse file tree 1 file changed +26
-13
lines changed Original file line number Diff line number Diff line change @@ -382,13 +382,14 @@ def umount_local(self):
382382 "CMD_ILISTDIR_NEXT" : 3 ,
383383 "CMD_OPEN" : 4 ,
384384 "CMD_CLOSE" : 5 ,
385- "CMD_READ" : 6 ,
386- "CMD_WRITE" : 7 ,
387- "CMD_SEEK" : 8 ,
388- "CMD_REMOVE" : 9 ,
389- "CMD_RENAME" : 10 ,
390- "CMD_MKDIR" : 11 ,
391- "CMD_RMDIR" : 12 ,
385+ "CMD_READLINE" : 6 ,
386+ "CMD_READ" : 7 ,
387+ "CMD_WRITE" : 8 ,
388+ "CMD_SEEK" : 9 ,
389+ "CMD_REMOVE" : 10 ,
390+ "CMD_RENAME" : 11 ,
391+ "CMD_MKDIR" : 12 ,
392+ "CMD_RMDIR" : 13 ,
392393}
393394
394395fs_hook_code = """\
@@ -571,12 +572,14 @@ def readinto(self, buf):
571572 return n
572573
573574 def readline(self):
574- l = ''
575- while 1:
576- c = self.read(1)
577- l += c
578- if c == '\\ n' or c == '':
579- return l
575+ c = self.cmd
576+ c.begin(CMD_READLINE)
577+ c.wr_s8(self.fd)
578+ n = c.rd_u32()
579+ buf = bytearray(n)
580+ c.rd_bytes(buf)
581+ c.end()
582+ return bytes(buf)
580583
581584 def readlines(self):
582585 ls = []
@@ -866,6 +869,15 @@ def do_read(self):
866869 self .wr_bytes (buf )
867870 # self.log_cmd(f"read {fd} {n} -> {len(buf)}")
868871
872+ def do_readline (self ):
873+ fd = self .rd_s8 ()
874+ buf = self .data_files [fd ][0 ].readline ()
875+ self .wr_u32 (len (buf ))
876+ if self .data_files [fd ][1 ]:
877+ buf = bytes (buf , "utf8" )
878+ self .wr_bytes (buf )
879+ # self.log_cmd(f"readline {fd} -> {len(buf)}")
880+
869881 def do_seek (self ):
870882 fd = self .rd_s8 ()
871883 n = self .rd_s32 ()
@@ -939,6 +951,7 @@ def do_rmdir(self):
939951 fs_hook_cmds ["CMD_OPEN" ]: do_open ,
940952 fs_hook_cmds ["CMD_CLOSE" ]: do_close ,
941953 fs_hook_cmds ["CMD_READ" ]: do_read ,
954+ fs_hook_cmds ["CMD_READLINE" ]: do_readline ,
942955 fs_hook_cmds ["CMD_WRITE" ]: do_write ,
943956 fs_hook_cmds ["CMD_SEEK" ]: do_seek ,
944957 fs_hook_cmds ["CMD_REMOVE" ]: do_remove ,
You can’t perform that action at this time.
0 commit comments