コード例 #1
0
ファイル: fs (copy).c プロジェクト: GoncaloBFM/DiskEmulator
int fs_format()
{
  if(mb.magic == FS_MAGIC) {
    printf("Refusing to format a mounted disk\n");
    return -1;
  }

  disk_read(0, (char *)&mb);
  if(mb.magic == FS_MAGIC){
    printf("Refusing to format a formatted disk!\n");
    mb.magic = 0;
    return -1;
  }

  //Format disk
  init_super_block();
  init_empty_dir();
  
  //Flush
  disk_write(0, (char*)&mb);
  disk_write(1, (char*)dir);

  mb.magic = 0; // mark disk as unmounted

  return 0;
}
コード例 #2
0
ファイル: chmod.c プロジェクト: 7perl/akaros
/* Change the protections of FILE to MODE.  */
int
__chmod (const char* file, mode_t mode)
{
  struct dir dir;
  size_t mlen;
  char mbuf[STATFIXLEN];
  int ret;

  if (file == NULL)
  {
    __set_errno (EINVAL);
    return -1;
  }

  init_empty_dir(&dir);
  dir.mode = mode;
  mlen = convD2M(&dir, mbuf, STATFIXLEN);
  ret = ros_syscall(SYS_wstat, file, strlen(file), mbuf, mlen, WSTAT_MODE, 0);
  return (ret == mlen ? 0 : -1);
}