func: static void v9fs_wstat(void *opaque) int32_t fid ; V9fsStat v9stat ; size_t offset = 7 ; V9fsFidState * fidp ; V9fsPDU * pdu = opaque ; V9fsState * s = pdu -> s ; err = pdu_unmarshal ( pdu , offset , "dwS" , & fid , & unused , & v9stat ); 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 ); if ( err < 0 )  return NULL ; return f ; return NULL ; if ( fidp == NULL )  err = - EINVAL; if ( donttouch_stat ( & v9stat ) )  static int donttouch_stat(V9fsStat *stat) if ( stat -> type == - 1 && stat -> dev == - 1 && stat -> qid . type == - 1 && stat -> qid . version == - 1 && stat -> qid . path == - 1 && stat -> mode == - 1 && stat -> atime == - 1 && stat -> mtime == - 1 && stat -> length == - 1 && ! stat -> name . size && ! stat -> uid . size && ! stat -> gid . size && ! stat -> muid . size && stat -> n_uid == - 1 && stat -> n_gid == - 1 && stat -> n_muid == - 1 )  return 1 ; return 0 ; err = v9fs_co_fsync ( pdu , fidp , 0 ); if ( v9stat . mode != - 1 )  uint32_t v9_mode ; err = v9fs_co_lstat ( pdu , & fidp -> path , & stbuf ); if ( err < 0 )  v9_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 ; if ( ( v9stat . mode & P9_STAT_MODE_TYPE_BITS ) != ( v9_mode & P9_STAT_MODE_TYPE_BITS ) )  err = - EIO; err = v9fs_co_chmod ( pdu , & fidp -> path , v9mode_to_mode ( v9stat . mode , & v9stat . extension ) ); static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension) mode_t ret ; ret = mode & 0777; if ( mode & P9_STAT_MODE_DIR )  ret |= S_IFDIR; if ( mode & P9_STAT_MODE_SYMLINK )  ret |= S_IFLNK; if ( mode & P9_STAT_MODE_SOCKET )  ret |= S_IFSOCK; if ( mode & P9_STAT_MODE_NAMED_PIPE )  ret |= S_IFIFO; if ( mode & P9_STAT_MODE_DEVICE )  if ( extension -> size && extension -> data [ 0 ] == 'c' )  ret |= S_IFCHR; ret |= S_IFBLK; if ( ! ( ret & ~0777 ) )  ret |= S_IFREG; if ( mode & P9_STAT_MODE_SETUID )  ret |= S_ISUID; if ( mode & P9_STAT_MODE_SETGID )  ret |= S_ISGID; if ( mode & P9_STAT_MODE_SETVTX )  ret |= S_ISVTX; return ret ; if ( err < 0 )  if ( v9stat . mtime != - 1 || v9stat . atime != - 1 )  struct timespec times [ 2 ] ; if ( v9stat . atime != - 1 )  times [ 0 ] . tv_sec = v9stat . atime; times [ 0 ] . tv_nsec = 0; times [ 0 ] . tv_nsec = UTIME_OMIT; if ( v9stat . mtime != - 1 )  times [ 1 ] . tv_nsec = UTIME_OMIT; err = v9fs_co_utimensat ( pdu , & fidp -> path , times ); if ( err < 0 )  if ( v9stat . n_gid != - 1 || v9stat . n_uid != - 1 )  err = v9fs_co_chown ( pdu , & fidp -> path , v9stat . n_uid , v9stat . n_gid ); if ( err < 0 )  if ( v9stat . name . size != 0 )  err = v9fs_complete_rename ( pdu , fidp , - 1 , & v9stat . name ); static int v9fs_complete_rename(V9fsPDU *pdu, V9fsFidState int32_t newdirfid, V9fsString *name) if ( newdirfid != - 1 )  dirfidp = get_fid ( pdu , newdirfid ); static V9fsFidState *get_fid(V9fsPDU *pdu, int32_t fid) int err ; V9fsFidState * f ; V9fsState * s = pdu -> s ; if ( f -> fid == fid )  f -> ref ++; err = v9fs_reopen_fid ( pdu , f ); if ( err < 0 )  return NULL ; return f ; return NULL ; if ( dirfidp == NULL )  err = - ENOENT; err = v9fs_co_rename ( pdu , & fidp -> path , & new_path ); return err ; if ( err < 0 )  if ( v9stat . length != - 1 )  err = v9fs_co_truncate ( pdu , & fidp -> path , v9stat . length ); if ( err < 0 )  err = offset; complete_pdu ( s , pdu , err ); static void complete_pdu(V9fsState *s, V9fsPDU *pdu, ssize_t len) if ( len < 0 )  int err = - len ; if ( s -> proto_version != V9FS_PROTO_2000L )  V9fsString str ; str . data = strerror ( err ); str . size = strlen ( str . data ); len += pdu_marshal ( pdu , len , "s" , & str ); len += pdu_marshal ( pdu , len , "d" , err ); pdu_marshal ( pdu , 0 , "dbw" , ( int32_t ) len , id , pdu -> tag ); pdu -> size = len; pdu -> id = id; virtqueue_push ( s -> vq , & pdu -> elem , len ); qemu_co_queue_next ( & pdu -> complete ); free_pdu ( s , pdu ); 