• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dir_close函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dir_close函数的典型用法代码示例。如果您正苦于以下问题:C++ dir_close函数的具体用法?C++ dir_close怎么用?C++ dir_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dir_close函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: calloc

static BD_DIR_H *_combine_dirs(BD_DIR_H *ovl, BD_DIR_H *rom)
{
    BD_DIR_H *dp = calloc(1, sizeof(BD_DIR_H));
    BD_DIRENT entry;

    if (dp) {
        dp->read     = _comb_dir_read;
        dp->close    = _comb_dir_close;
        dp->internal = calloc(1, sizeof(COMB_DIR));
        if (!dp->internal) {
            X_FREE(dp);
            goto out;
        }

        while (!dir_read(ovl, &entry)) {
            _comb_dir_append(dp, &entry);
        }
        while (!dir_read(rom, &entry)) {
            _comb_dir_append(dp, &entry);
        }
    }

 out:
    dir_close(ovl);
    dir_close(rom);

    return dp;
}
开发者ID:Paxxi,项目名称:libbluray,代码行数:28,代码来源:disc.c


示例2: filesys_create

/* Creates a file named NAME with the given INITIAL_SIZE.
   Returns true if successful, false otherwise.
   Fails if a file named NAME already exists,
   or if internal memory allocation fails. */
bool
filesys_create (const char *name, off_t initial_size, enum file_type type) 
{
  block_sector_t inode_sector = 0;

  char * parse = parse_filename (name); 
  //get the correct dir

  struct dir *dir = dir_lookup_rec (parse);

  bool success = (dir != NULL
                  && free_map_allocate (1, &inode_sector)
                  && inode_create (inode_sector, initial_size, type)
                  && dir_add (dir, parse, inode_sector));

  if (!success && inode_sector != 0) 
    free_map_release (inode_sector, 1);
  if( success == true && type == FILE_DIR ) {
	//we want to add . and .. as well if it is a dir
		//open the created directory
		struct file * created = filesys_open(parse);
		struct dir * mydir = dir_open(file_get_inode (created));
		//add . to it
		dir_add (mydir, ".", inode_sector);
		struct inode * parent = dir_get_inode (dir);
		block_sector_t inode_sector_parent = inode_id(parent);
		//add .. to it
		dir_add (mydir, "..", inode_sector_parent);
		dir_close(mydir);
		file_close(created);
  }
  dir_close (dir);

  return success;
}
开发者ID:c22dunbar,项目名称:sven-pintos-code,代码行数:39,代码来源:filesys.c


示例3: filesys_cd

bool filesys_cd (const char* dir)
{
  bool result = false;
  char* name_;
  if (strlen(dir) == 0) {
    return false;
  } else {
    struct dir* dir_ = filesys_get_dir(dir);
    name_ = filesys_get_name(dir);
    struct inode* inode = NULL;
    bool isdir = false;

    if (strcmp(name_, "") == 0) {
      if (thread_current()->cur_dir) 
        dir_close(thread_current()->cur_dir);
      thread_current()->cur_dir = dir_;
      result = true;
    } else if (dir_lookup(dir_, name_, &inode, &isdir) ==NULL ||
               isdir == NULL) {
      dir_close(dir_);
      result = false;
    } else if (isdir != NULL){
      if (thread_current()->cur_dir)
        dir_close(thread_current()->cur_dir);
      thread_current()->cur_dir = dir_open(inode);
      dir_close(dir_);
      result = true;
    }
  }
  free(name_);
  return result;
}
开发者ID:gypintos,项目名称:np4,代码行数:32,代码来源:filesys.c


示例4: filesys_get_dir

static struct dir* filesys_get_dir (const char* path)
{
  struct dir* dir;
  int len = strlen(path);
  char *p = (char *)malloc(sizeof(char) * (len + 1));
  memcpy(p, path, len);
  p[len]='\0';

  bool openRoot = p[0]=='/' || thread_current ()->cur_dir == NULL;
  dir = openRoot ? dir_open_root() : dir_reopen(thread_current()->cur_dir);

  char *save_ptr;
  char *token = strtok_r(p, "/", &save_ptr);
  char *next_token = token!=NULL ? strtok_r(NULL, "/", &save_ptr): NULL;
  struct inode *inode;
  bool isdir;

  while (next_token!=NULL){
    if (dir_lookup(dir, token, &inode, &isdir) == NULL) return NULL;
    dir_close(dir);
    dir = dir_open(inode);
    if (isdir == false){
      dir_close(dir);
      return NULL;
    }
    token = next_token;
    next_token = strtok_r(NULL, "/", &save_ptr);
  }
  return dir;

}
开发者ID:gypintos,项目名称:np4,代码行数:31,代码来源:filesys.c


示例5: filesys_open

/* Opens the file with the given NAME.
   Returns the new file if successful or a null pointer
   otherwise.
   Fails if no file named NAME exists,
   or if an internal memory allocation fails. */
struct file *
filesys_open (const char *name)
{
  struct dir *dir;
  struct inode *inode = NULL;
  char parsed_name[NAME_MAX + 1];
  if (*name == NULL)
    {
      return NULL;
    }

  bool success = parse_path (name, &dir, parsed_name);
  if ((strlen (parsed_name) > NAME_MAX))
    {
      dir_close (dir);
      return NULL;
    }

  if (success)
  {
    if (dir != NULL)
       dir_lookup (dir, parsed_name, &inode);
    dir_close (dir);
  }
  struct file *result = file_open (inode);
  return result;
}
开发者ID:jackykschou,项目名称:pintos,代码行数:32,代码来源:filesys.c


示例6: filesys_chdir

bool filesys_chdir (const char* name)
{
  struct dir* dir = containing_dir(name);
  char* file_name = get_name(name);
  struct inode *inode = NULL;

  if (dir != NULL){
      if (strcmp(file_name, "..") == 0){
        //Check parent
        if (!dir_parent(dir, &inode)){
            free(file_name);
            return false;
          }
      }
      else if ((strlen(file_name) == 0 && (dir_is_root(dir))) || (strcmp(file_name, ".") == 0)){
        thread_current()->cur_dir = dir;
        free(file_name);
        return true;
      }else{
        dir_lookup (dir, file_name, &inode);
      }
  }

  dir_close (dir);
  free(file_name);

  dir = dir_open(inode);
  if (dir)
    {
      dir_close(thread_current()->cur_dir);
      thread_current()->cur_dir = dir;
      return true;
    }
  return false;
}
开发者ID:liyu1390,项目名称:CS162_group,代码行数:35,代码来源:filesys.c


示例7: filesys_remove

/* Deletes the file named NAME.
   Returns true if successful, false on failure.
   Fails if no file named NAME exists,
   or if an internal memory allocation fails. */
bool
filesys_remove (const char *name)
{
    char leaf_name[NAME_MAX + 1];
    if (!dir_get_leaf_name (name, leaf_name))
        return false;

    struct dir *parent_dir = dir_get_parent_dir (name);

    if (parent_dir == NULL)
        return false;

    struct inode *inode;
    if (!dir_lookup (parent_dir, leaf_name, &inode))
    {
        dir_close (parent_dir);
        return false;
    }

    bool success;
    if (!inode_is_dir(inode)) // if is file
        success = dir_remove (parent_dir, leaf_name);
    else
    {
        if (dir_is_empty (inode))
        {
            success = dir_remove (parent_dir, leaf_name);
        }
        else
            success = false;
    }

    dir_close (parent_dir);
    return success;
}
开发者ID:rahulabc,项目名称:jawpintos,代码行数:39,代码来源:filesys.c


示例8: filesys_open

/* Opens the file with the given NAME.
   Returns the new file if successful or a null pointer
   otherwise.
   Fails if no file named NAME exists,
   or if an internal memory allocation fails. */
struct file *
filesys_open (const char *name)
{
    if (strnlen (name, FULLPATH_MAX_LEN) == 0)
        return NULL;

    if (strcmp (".", name) == 0)
    {
        block_sector_t cwd = thread_current ()->cwd_sector;
        struct inode *curr = NULL;
        curr = inode_open (cwd);

        struct dir *p;
        p = dir_open (inode_open (curr->data.parent_dir_sector));

        struct dir_entry e;
        size_t ofs;

        ASSERT (p != NULL);

        for (ofs = 0;
                inode_read_at (p->inode, &e, sizeof e, ofs) == sizeof e;
                ofs += sizeof e)
        {
            if (e.inode_sector == cwd && e.in_use)
            {
                return filesys_open (e.name);
            }
        }
        return NULL;
    }
    struct inode *crr = NULL;
    crr = inode_open (thread_current ()->cwd_sector);

    struct dir *parent_dir = dir_reopen(dir_get_parent_dir (name));
    //if (crr->data.is_dir)
    //parent_dir = dir_open (inode_open (crr->data.parent_dir_sector));
    //else
    if (parent_dir == NULL)
        return NULL;

    struct inode *inode = NULL;

    char leaf_name[NAME_MAX + 1];
    if (!dir_get_leaf_name (name, leaf_name) &&
            strnlen(leaf_name, NAME_MAX) == 0)
    {
        inode = inode_reopen (dir_get_inode (parent_dir));
        dir_close (parent_dir);
        return file_open (inode);
    }

    if (parent_dir != NULL)
        dir_lookup (parent_dir, leaf_name, &inode);
    dir_close (parent_dir);

    return file_open (inode);
}
开发者ID:rahulabc,项目名称:jawpintos,代码行数:63,代码来源:filesys.c


示例9: dir_remove

/* Removes any entry for NAME in DIR.
   Returns true if successful, false on failure,
   which occurs only if there is no file with the given NAME. */
bool
dir_remove (struct dir *dir, const char *name) 
{
  struct dir_entry e;
  struct inode *inode = NULL;
  bool success = false;
  off_t ofs;

  ASSERT (dir != NULL);
  ASSERT (name != NULL);

  //lock the directory for the rest of the lookup operation
  inode_lock(dir->inode);
  name = getfilename(name);

  /* Find directory entry. */
  if (!lookup (dir, name, &e, &ofs))
    goto done;

  /* Open inode. */
  inode = inode_open (e.inode_sector);
  if (inode == NULL)
    goto done;

  //if it is still open don't allow deletion
  if(inode_type(inode) == FILE_DIR) {
	//is file in use?
	if(inode_opencnt(inode) > 1)
		goto done;
	char * temp = (char *)malloc(sizeof(char) * (NAME_MAX + 1) );
	struct dir * dirtemp = dir_open(inode);
	//is dir empty?
	if (dir_readdir(dirtemp,temp)) {
		free(temp);
		dir_close(dirtemp);
		goto done;
	}
	free(temp);
	dir_close(dirtemp);	
  }

  /* Erase directory entry. */
  e.in_use = false;
  if (inode_write_at (dir->inode, &e, sizeof e, ofs) != sizeof e) 
    goto done;

  /* Remove inode. */
  inode_remove (inode);
  success = true;

 done:
  //unlock the directory
  inode_unlock(dir->inode);
  inode_close (inode);
  return success;
}
开发者ID:c22dunbar,项目名称:sven-pintos-code,代码行数:59,代码来源:directory.c


示例10: malloc

struct dir *get_directory(const char *path, bool flag){
  if(strlen(path)==0)
    return NULL;
  struct dir *curr;
  char *word, *brkt, *buffer = malloc(strlen(path)+1), *save, *last;
  struct inode *inode;
  memcpy(buffer, path, strlen(path)+1);
  save = buffer;
  if(buffer[0]=='/'){
    curr = dir_open_root();
    last = strtok_r(buffer+1, "/", &brkt);
  }
  else{
    if(thread_current()->dir)
      curr = dir_reopen(thread_current()->dir);
    else
      curr = dir_open_root();
    last = strtok_r(buffer, "/", &brkt);
  }
  
  while(1){
    word = last;
    if(word == NULL) break;
    last = strtok_r(NULL, "/", &brkt);
    if(last == NULL && flag) break;
    if(strcmp(word,"")==0);
    else if(strcmp(word,".")==0);
    else if(strcmp(word,"..")==0){
      inode = inode_open(inode_parent_number(dir_get_inode(curr)));
      dir_close(curr);
      curr = dir_open(inode);
    }
    else{
      inode = NULL;
      if(dir_lookup(curr, word, &inode)){
        dir_close(curr);
        if(inode_is_dir(inode))
          curr = dir_open(inode);
        else{
          inode_close(inode);
          free(save);
          return NULL;
        }
      }
      else{
        dir_close(curr);
        free(save);
        return NULL;
      }
    }
  }
  free(save);
  if(inode_removed(curr->inode))
    return NULL;
  return curr;
}
开发者ID:mjy0503,项目名称:pintos,代码行数:56,代码来源:directory.c


示例11: exit_handler

void exit_handler (int status) {

  printf("%s: exit(%d)\n", &thread_current ()->name, status);

  lock_acquire(&ref_count_lock);
  struct p_data* parent = thread_current()->parent_data;
  if (parent != NULL) {
    parent->exit_status = status;
    parent->child_thread = NULL;
    sema_up(&parent->sema);
    parent->ref_count--;
    if (parent->cwd != NULL) {
      dir_close(parent->cwd);
    }
    if (parent->ref_count == 0) {
      thread_current()->parent_data = NULL;
      free(parent);

    }
  }
  if (thread_current()->cwd != NULL) {
    dir_close(thread_current()->cwd);
  }
  /* iterate through children and remove this as their parent*/
  struct list_elem* e;
  struct list *childs = &thread_current()->child_processes;
  for (e = list_begin(childs); e != list_end(childs); e = list_next(e)) {
    struct p_data* child = list_entry(e, struct p_data, elem);
    child->ref_count --;
    list_remove(e);
    if (child->ref_count == 0) {
      struct thread *t = child->child_thread;
      if (t != NULL) {
        t->parent_data = NULL;
      }
      free(child);
    }
  }

  struct list *files = &thread_current()->files;
  for (e = list_begin(files); e != list_end(files); e = list_begin(files)) {
    close_handler(list_entry(e, struct file_struct, elem)->fd);
  }
  struct file_struct *executable = thread_current()->executable;
  if (executable != NULL) {
    file_allow_write(executable->sys_file);
    file_close(executable->sys_file);
    thread_current()->executable = NULL;
    free(executable);
  }
  lock_release(&ref_count_lock);
  thread_exit();
}
开发者ID:tonychenr,项目名称:CS162-group34,代码行数:53,代码来源:syscall.c


示例12: filesys_mkdir

/* Creates directory. True if successful. */
bool 
filesys_mkdir (const char *dir)
{
  bool success = false;

  /*The string *dir cannot be empty.*/
  if (*dir == NULL)
    {
      return success;
    }

  /* Locates the directory where the new directory should be created. */
  struct dir *create_dir;
  char parsed_name[NAME_MAX + 1];
  parse_path (dir, &create_dir, parsed_name);

  block_sector_t sector;
  /*Find a free sector for the directory.*/
  if (!free_map_allocate (1, &sector))
    {
      return success;
    }

  success = dir_create (sector, 16);
  if (!success)
    {
      free_map_release (sector, 1);
      return success;
    }

  success = dir_add (create_dir, parsed_name, sector);
  if (!success)
    {
      free_map_release (sector, 1);
      return success;
    }

  /* Get the dir struct of the directory that is just created and add "." and "..". */
  struct inode *inode = inode_open (sector);
  struct dir *new_dir = dir_open (inode);

  ASSERT (inode != NULL);
  ASSERT (new_dir != NULL);

  dir_add (new_dir, ".", sector);
  dir_add (new_dir, "..", create_dir->inode->sector);
  dir_close (new_dir);
  dir_close (create_dir);

  return success; 
}
开发者ID:jackykschou,项目名称:pintos,代码行数:52,代码来源:filesys.c


示例13: filesys_open

/* Opens the file with the given NAME.
   Returns the new file if successful or a null pointer
   otherwise.
   Fails if no file named NAME exists,
   or if an internal memory allocation fails. */
struct inode *
filesys_open (const char *name)
{
  struct dir *search_dir = get_cwd(name);

  if (search_dir == NULL) {
    return NULL;
  }

  struct inode *inode = NULL;

  if (name[0] == '/') {
    inode = dir_get_inode(search_dir);
  }

  char *part = malloc(NAME_MAX + 1);
  if (part == NULL) {
    return false;
  }
  memset(part, 0, NAME_MAX + 1);
  int retrieved_next_part;
  for (retrieved_next_part = get_next_part(part, &name); retrieved_next_part > 0;
       retrieved_next_part = get_next_part(part, &name)) {
    if (dir_lookup (search_dir, part, &inode)) {
      if (!inode_is_dir(inode)) {
        break;
      } else {
        dir_close(search_dir);
        search_dir = dir_open(inode);
        if (search_dir == NULL) {
          free(part);
          return false;
        }
      }
    } else {
      inode = NULL;
      break;
    }
  }
  if (inode != NULL && inode_is_dir(inode) && get_next_part(part, &name) == 0) {
    inode = inode_reopen(inode);
  }
  dir_close(search_dir);
  
  if (inode != NULL && get_next_part(part, &name) != 0) {
    inode_close(inode);
    inode = NULL;
  }
  free(part);
  return inode;
}
开发者ID:tonychenr,项目名称:CS162-group34,代码行数:56,代码来源:filesys.c


示例14: filesys_chdir

/* changes the current working directory to path */
bool filesys_chdir(const char *path)
{
  struct dir *dir = get_containing_dir(path);
  char *file_name = get_file_name(path);
  struct inode *inode = NULL;
  struct thread *cur = thread_current();

  if (dir != NULL)
  {
    if(strcmp(file_name, "..") == 0)
    {
      if(!dir_get_parent(dir, &inode))
      {
	free(file_name);
	return false;
      }
    }
    else if(strcmp(file_name, ".") == 0)
    {
      cur->cwd = dir;
      free(file_name);
      return true;
    }
    else if(dir_is_root(dir) && strlen(file_name) == 0)
    {
      cur->cwd = dir;
      free(file_name);
      return true;
    }
    else
    {
      dir_lookup (dir, file_name, &inode);
    }
  }

  dir_close(dir);
  free(file_name);

  dir = dir_open(inode);
  if(dir != NULL) 
  {
    dir_close(cur->cwd);
    cur->cwd = dir;
    return true;
  }

  return false;
}
开发者ID:YeongjinOh,项目名称:Operating-System,代码行数:49,代码来源:filesys.c


示例15: dir_open

dir_t*
dir_open(char *path) {
    dir_t *d=0;
    int i, err = -1;
    char *p=0;
    do {
	i = strlen(path)+4;
	p = malloc(i);
	assertb(p);
	strncpy(p, path, i);
	strncat(p, "/*", i);

	d = calloc(1, sizeof(*d));
	assertb(d);
	d->h = INVALID_HANDLE_VALUE;

	d->h = FindFirstFile(p, &d->fi);
	if(d->h == INVALID_HANDLE_VALUE 
	   && GetLastError() == ERROR_NO_MORE_FILES) {
	    break;
	}
	assertb_syserr(d->h);
	d->first = 1;
	err = 0;
    } while(0);
    if( p ) {
	free(p);
    }
    if( err ) {
	dir_close(d);
	d = 0;
    }
    return d;
}
开发者ID:noelbk,项目名称:bklib,代码行数:34,代码来源:dir_win32.c


示例16: filesys_open_inode

struct inode *
filesys_open_inode (const char *path, bool *is_directory)
{
  struct dir *dir = NULL;
  struct inode *inode = NULL;
  bool success = false;
  char *name = malloc (NAME_MAX + 1);
  if (name == NULL)
    goto done;
  if (!dir_follow_path (thread_current ()->cwd, path, &dir, name))
    goto done;
  if (dir == NULL)
    goto done;

  /* open directory in this case */
  if (*path != '\0' && strlen (name) == 0)
  {
    inode = inode_reopen (dir_get_inode (dir));
    if (inode == NULL)
      goto done;
    *is_directory = true;
  }
  else if (!dir_lookup (dir, name, &inode, is_directory))
    goto done;
  success = true;
done:
  dir_close (dir);
  free (name);
  return success ? inode : NULL;
}
开发者ID:kcm1700,项目名称:ChoPintOS,代码行数:30,代码来源:filesys.c


示例17: moddir_glob

static int moddir_glob( INSTANCE * my, int * params )
{
    const char * path = string_get( params[ 0 ] );
    static __DIR_ST * dh = NULL;
    int result;

    if ( dh && strcmp( dh->path, path ) )
    {
        dir_close( dh );
        dh = NULL;
    }

    if ( !dh ) dh = dir_open( path );

    string_discard( params[ 0 ] );

    if ( !dh )
    {
        result = string_new( "" );
        string_use( result );
        return ( result );
    }

    return ( __moddir_read( dh ) ) ;
}
开发者ID:GarethNelson,项目名称:BennuGD,代码行数:25,代码来源:mod_dir.c


示例18: _findMetaXMLfiles

static void _findMetaXMLfiles(META_ROOT *meta, BD_DISC *disc)
{
    BD_DIR_H *dir;
    BD_DIRENT ent;
    dir = disc_open_dir(disc, "BDMV" DIR_SEP "META" DIR_SEP "DL");
    if (dir == NULL) {
        BD_DEBUG(DBG_DIR, "Failed to open meta dir BDMV/META/DL/\n");
        return;
    }
    int res;
    for (res = dir_read(dir, &ent); !res; res = dir_read(dir, &ent)) {
        if (ent.d_name[0] == '.')
            continue;
        else if (strncasecmp(ent.d_name, "bdmt_", 5) == 0) {
            META_DL *new_dl_entries = realloc(meta->dl_entries, ((meta->dl_count + 1)*sizeof(META_DL)));
            if (new_dl_entries) {
                uint8_t i = meta->dl_count;
                meta->dl_count++;
                meta->dl_entries = new_dl_entries;
                memset(&meta->dl_entries[i], 0, sizeof(meta->dl_entries[i]));

                meta->dl_entries[i].filename = str_dup(ent.d_name);
                strncpy(meta->dl_entries[i].language_code, ent.d_name+5,3);
                meta->dl_entries[i].language_code[3] = '\0';
                str_tolower(meta->dl_entries[i].language_code);
            }
        }
    }
    dir_close(dir);
}
开发者ID:mwgoldsmith,项目名称:bluray,代码行数:30,代码来源:meta_parse.c


示例19: filesys_open

/* Opens the file with the given NAME.
   Returns the new file if successful or a null pointer
   otherwise.
   Fails if no file named NAME exists,
   or if an internal memory allocation fails. */
struct file *
filesys_open (const char *name)
{
  char s[100];
  char *save_ptr;
//  printf("%s \n",name);
  memcpy(s,name,strlen(name)+1);
  struct inode *inode = NULL;
  char *file_name = get_file_name(name);
//  printf("file name : %s\n",file_name);
  if( strtok_r(s,"/",&save_ptr) ==NULL&&strlen(name)>0 )
  {
//    printf("aaa\n");  
    free(file_name);
    return file_open(inode_open(1));
  }
  if( strcmp(file_name,"")==0 )
    return NULL;
  struct dir *dir = get_directory(name);
//  printf("sector of dir :  %d\n", inode_get_inumber(dir_get_inode(dir)));
//  printf("lookup start\n");
  if (dir != NULL)
  {
//    printf("here?\n");
    if(strcmp(file_name,".")==0)
    {
      //      printf("here\n");
      inode = dir_get_inode(dir);
      //      printf("ohhhhhh\n");
      //  dir_close (dir);
      free(file_name);
      if(inode_is_removed(inode))
        return NULL;
      else
        return file_open (inode);
    }
    else if( strcmp(file_name,"..")==0)
    {
      inode = dir_get_inode(inode);
      //      dir_close (dir);
      free(file_name);
      return file_open (inode);
    }
    else
      dir_lookup (dir, file_name, &inode);
    dir_close (dir);
    if(inode==NULL)
      return NULL;
    free(file_name);
    return file_open (inode);
  }
  else
  {
//    printf("here\n");
    return NULL;
  }
//  if(inode_is_removed(inode))
//    return NULL;
//  return file_open (inode);
}
开发者ID:goodahn,项目名称:cs330_OperatingSystem,代码行数:65,代码来源:filesys.c


示例20: filesys_create

/* Creates a file named NAME with the given INITIAL_SIZE.
   Returns true if successful, false otherwise.
   Fails if a file named NAME already exists,
   or if internal memory allocation fails. */
bool
filesys_create (const char *name, off_t initial_size) 
{

  block_sector_t inode_sector = 0;
  struct dir *dir;
  char parsed_name[NAME_MAX + 1];
  
  if (*name == NULL || (strlen (name) > NAME_MAX))
    {
      return false;
    }
  bool success = parse_path (name, &dir, parsed_name);
  if (!success)
    {
      return success;
    }

  struct inode *inode;

  success = (dir != NULL
                  && free_map_allocate (1, &inode_sector)
                  && inode_create (inode_sector, initial_size, false)
                  && dir_add (dir, parsed_name, inode_sector)
                  && dir_lookup (dir, ".", &inode));
  if (!success && inode_sector != 0) 
    free_map_release (inode_sector, 1);
  dir_close (dir);


  return success;
}
开发者ID:jackykschou,项目名称:pintos,代码行数:36,代码来源:filesys.c



注:本文中的dir_close函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dir_emit函数代码示例发布时间:2022-05-30
下一篇:
C++ dir2函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap