client/src/unifycr.c
int unifycr_fid_stat(int fid, struct stat* buf)
{
   unifycr_filemeta_t* meta = unifycr_get_meta_from_fid(fid);
   if (meta == NULL) {
      return -1;
   }
   
   /* initialize all the values */
   buf->st_dev = 0;     /* ID of device containing file */
   buf->st_ino = 0;     /* inode number */
   buf->st_mode = 0;    /* protection */
   buf->st_nlink = 0;   /* number of hard links */
   buf->st_uid = 0;     /* user ID of owner */
   buf->st_gid = 0;     /* group ID of owner */
   buf->st_rdev = 0;    /* device ID (if special file) */
   buf->st_size = 0;    /* total size, in bytes */
   buf->st_blksize = 0; /* blocksize for file system I/O */
   buf->st_blocks = 0;  /* number of 512B blocks allocated */
   buf->st_atime = 0;   /* time of last access */
   buf->st_mtime = 0;   /* time of last modification */
   buf->st_ctime = 0;   /* time of last status change */

   /* set the file size */
   buf->st_size = meta->size;

   /* specify whether item is a file or directory */
   if(unifycr_fid_is_dir(fid)) {
      buf->st_mode |= S_IFDIR;
   } else {
      buf->st_mode |= S_IFREG;
   }

   return 0;
}
/* fill in limited amount of stat information */
fill in limited amount of stat information
fill in limited amount of stat information
int unifycr_fid_stat(int fid, struct stat* buf)
{
   unifycr_filemeta_t* meta = unifycr_get_meta_from_fid(fid);
   if (meta == NULL) {
      return -1;
   }
   buf->st_dev = 0;     
   buf->st_ino = 0;     
   buf->st_mode = 0;    
   buf->st_nlink = 0;   
   buf->st_uid = 0;     
   buf->st_gid = 0;     
   buf->st_rdev = 0;    
   buf->st_size = 0;    
   buf->st_blksize = 0; 
   buf->st_blocks = 0;  
   buf->st_atime = 0;   
   buf->st_mtime = 0;   
   buf->st_ctime = 0;   
   buf->st_size = meta->size;
   if(unifycr_fid_is_dir(fid)) {
      buf->st_mode |= S_IFDIR;
   } else {
      buf->st_mode |= S_IFREG;
   }
   return 0;
}
int unifycr_fid_stat ( int fid , struct stat * buf ) { unifycr_filemeta_t * meta = unifycr_get_meta_from_fid ( fid ) ; if ( meta == NULL ) { return -1 ; } buf -> st_dev = 0 ; buf -> st_ino = 0 ; buf -> st_mode = 0 ; buf -> st_nlink = 0 ; buf -> st_uid = 0 ; buf -> st_gid = 0 ; buf -> st_rdev = 0 ; buf -> st_size = 0 ; buf -> st_blksize = 0 ; buf -> st_blocks = 0 ; buf -> st_atime = 0 ; buf -> st_mtime = 0 ; buf -> st_ctime = 0 ; buf -> st_size = meta -> size ; if ( unifycr_fid_is_dir ( fid ) ) { buf -> st_mode |= S_IFDIR ; } else { buf -> st_mode |= S_IFREG ; } return 0 ; }
fill in limited amount of stat information
fill in limited amount of stat information
/* initialize all the values */ /* ID of device containing file */ /* inode number */ /* protection */ /* number of hard links */ /* user ID of owner */ /* group ID of owner */ /* device ID (if special file) */ /* total size, in bytes */ /* blocksize for file system I/O */ /* number of 512B blocks allocated */ /* time of last access */ /* time of last modification */ /* time of last status change */ /* set the file size */ /* specify whether item is a file or directory */