func: static void v9fs_create(void *opaque) int32_t fid ; size_t offset = 7 ; V9fsFidState * fidp ; V9fsQID qid ; int32_t perm ; int8_t mode ; struct stat stbuf ; V9fsString name ; V9fsString extension ; V9fsPDU * pdu = opaque ; err = pdu_unmarshal ( pdu , offset , "dsdbs" , & fid , & name , & perm , & mode , & extension ); 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 )  if ( perm & P9_STAT_MODE_DIR )  err = v9fs_co_mkdir ( pdu , fidp , & name , perm & 0777 , fidp -> uid , - 1 , & stbuf ); if ( err < 0 )  err = v9fs_co_name_to_path ( pdu , & fidp -> path , name . data , & path ); if ( err < 0 )  err = v9fs_co_opendir ( pdu , fidp ); if ( err < 0 )  if ( perm & P9_STAT_MODE_SYMLINK )  err = v9fs_co_symlink ( pdu , fidp , & name , extension . data , - 1 , & stbuf ); if ( err < 0 )  err = v9fs_co_name_to_path ( pdu , & fidp -> path , name . data , & path ); if ( err < 0 )  if ( perm & P9_STAT_MODE_LINK )  int32_t ofid = atoi ( extension . data ) ; V9fsFidState * ofidp = get_fid ( pdu , ofid ) ; 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 ( ofidp == NULL )  err = v9fs_co_link ( pdu , ofidp , fidp , & name ); if ( err < 0 )  err = v9fs_co_name_to_path ( pdu , & fidp -> path , name . data , & path ); if ( err < 0 )  err = v9fs_co_lstat ( pdu , & fidp -> path , & stbuf ); if ( err < 0 )  if ( perm & P9_STAT_MODE_DEVICE )  char ctype ; uint32_t major , minor ; if ( sscanf ( extension . data , "%c %u %u" , & ctype , & major , & minor ) != 3 )  switch ( ctype )  nmode = S_IFCHR; nmode = S_IFBLK; err = - EIO; nmode |= perm & 0777; err = v9fs_co_mknod ( pdu , fidp , & name , fidp -> uid , - 1 , makedev ( major , minor ) , nmode , & stbuf ); if ( err < 0 )  err = v9fs_co_name_to_path ( pdu , & fidp -> path , name . data , & path ); if ( err < 0 )  if ( perm & P9_STAT_MODE_NAMED_PIPE )  err = v9fs_co_mknod ( pdu , fidp , & name , fidp -> uid , - 1 , 0 , S_IFIFO | ( perm & 0777 ) , & stbuf ); if ( err < 0 )  err = v9fs_co_name_to_path ( pdu , & fidp -> path , name . data , & path ); if ( err < 0 )  if ( perm & P9_STAT_MODE_SOCKET )  err = v9fs_co_mknod ( pdu , fidp , & name , fidp -> uid , - 1 , 0 , S_IFSOCK | ( perm & 0777 ) , & stbuf ); if ( err < 0 )  err = v9fs_co_name_to_path ( pdu , & fidp -> path , name . data , & path ); if ( err < 0 )  err = v9fs_co_open2 ( pdu , fidp , & name , - 1 , omode_to_uflags ( mode ) | O_CREAT , perm , & stbuf ); static int omode_to_uflags(int8_t mode) int ret = 0 ; switch ( mode & 3 )  ret = O_RDONLY; ret = O_RDWR; ret = O_WRONLY; ret = O_RDONLY; if ( mode & Otrunc )  ret |= O_TRUNC; if ( mode & Oappend )  ret |= O_APPEND; if ( mode & Oexcl )  ret |= O_EXCL; return ret ; if ( err < 0 )  stat_to_qid ( & stbuf , & qid ); static void stat_to_qid(const struct stat *stbuf, V9fsQID *qidp) size_t size ; memset ( & qidp -> path , 0 , sizeof ( qidp -> path ) ); size = MIN ( sizeof ( stbuf -> st_ino ) , sizeof ( qidp -> path ) ); memcpy ( & qidp -> path , & stbuf -> st_ino , size ); qidp -> version = stbuf -> st_mtime ^ ( stbuf -> st_size << 8 ); qidp -> type = 0; qidp -> type |= P9_QID_TYPE_DIR; qidp -> type |= P9_QID_TYPE_SYMLINK; 