func: static void v9fs_stat(void *opaque) int32_t fid ; size_t offset = 7 ; V9fsFidState * fidp ; V9fsPDU * pdu = opaque ; err = pdu_unmarshal ( pdu , offset , "d" , & fid ); if ( err < 0 )  fidp = get_fid ( pdu , fid ); static V9fsFidState *get_fid(V9fsPDU *pdu, int32_t fid) int err ; V9fsFidState * f ; V9fsState * s = pdu -> s ; for (f = s->fid_list; f; f = f->next) if ( f -> fid == fid )  f -> ref ++; err = v9fs_reopen_fid ( pdu , f ); static int v9fs_reopen_fid(V9fsPDU *pdu, V9fsFidState *f) int err = 1 ; if ( f -> fid_type == P9_FID_FILE )  if ( f -> fs . fd == - 1 )  err = v9fs_co_open ( pdu , f , f -> open_flags ); while ( err == - EINTR && ! pdu -> cancelled )  if ( f -> fid_type == P9_FID_DIR )  if ( f -> fs . dir == NULL )  err = v9fs_co_opendir ( pdu , f ); while ( err == - EINTR && ! pdu -> cancelled )  return err ; if ( err < 0 )  return NULL ; f -> flags |= FID_REFERENCED; return f ; return NULL ; if ( fidp == NULL )  err = v9fs_co_lstat ( pdu , & fidp -> path , & stbuf ); if ( err < 0 )  err = stat_to_v9stat ( pdu , & fidp -> path , & stbuf , & v9stat ); static int stat_to_v9stat(V9fsPDU *pdu, V9fsPath const struct stat V9fsStat *v9stat) int err ; const char * str ; memset ( v9stat , 0 , sizeof ( * v9stat ) ); v9stat -> mode = stat_to_v9mode ( stbuf ); static uint32_t stat_to_v9mode(const struct stat *stbuf) uint32_t mode ; mode = stbuf -> st_mode & 0777; if ( S_ISDIR ( stbuf -> st_mode ) )  mode |= P9_STAT_MODE_DIR; if ( S_ISLNK ( stbuf -> st_mode ) )  mode |= P9_STAT_MODE_SYMLINK; if ( S_ISSOCK ( stbuf -> st_mode ) )  mode |= P9_STAT_MODE_SOCKET; if ( S_ISFIFO ( stbuf -> st_mode ) )  mode |= P9_STAT_MODE_NAMED_PIPE; if ( S_ISBLK ( stbuf -> st_mode ) || S_ISCHR ( stbuf -> st_mode ) )  mode |= P9_STAT_MODE_DEVICE; if ( stbuf -> st_mode & S_ISUID )  mode |= P9_STAT_MODE_SETUID; if ( stbuf -> st_mode & S_ISGID )  mode |= P9_STAT_MODE_SETGID; if ( stbuf -> st_mode & S_ISVTX )  mode |= P9_STAT_MODE_SETVTX; return mode ; v9stat -> atime = stbuf -> st_atime; v9stat -> mtime = stbuf -> st_mtime; v9stat -> length = stbuf -> st_size; v9stat -> n_uid = stbuf -> st_uid; v9stat -> n_gid = stbuf -> st_gid; v9stat -> n_muid = 0; if ( v9stat -> mode & P9_STAT_MODE_SYMLINK )  err = v9fs_co_readlink ( pdu , name , & v9stat -> extension ); if ( err < 0 )  str = strrchr ( name -> data , '/' ); if ( str )  str += 1; v9fs_string_sprintf ( & v9stat -> name , "%s" , str ); 