Пример #1
0
int ext2fs_open (const char *filename) {
    struct ext2fs_node *fdiro = NULL;
    int status;
    int len;

    if (ext2fs_root == NULL) {
        return (-1);
    }
    ext2fs_file = NULL;
    status = ext2fs_find_file (filename, &ext2fs_root->diropen, &fdiro,
                   FILETYPE_REG);
    if (status == 0) {
        goto fail;
    }
    if (!fdiro->inode_read) {
        status = ext2fs_read_inode (fdiro->data, fdiro->ino,
                        &fdiro->inode);
        if (status == 0) {
            goto fail;
        }
    }
    len = __le32_to_cpu (fdiro->inode.size);
    ext2fs_file = fdiro;
    return (len);

fail:
    ext2fs_free_node (fdiro, &ext2fs_root->diropen);
    return (-1);
}
Пример #2
0
int ext2fs_ls (const char *dirname) {
    struct ext2fs_node *dirnode;
    int status;

    if (ext2fs_root == NULL) {
        return (0);
    }

    status = ext2fs_find_file (dirname, &ext2fs_root->diropen, &dirnode,
                   FILETYPE_DIRECTORY);
    if (status != 1) {
        printf ("** Can not find directory. **\n");
        return (1);
    }
    ext2fs_iterate_dir (dirnode, NULL, NULL, NULL);
    ext2fs_free_node (dirnode, &ext2fs_root->diropen);
    return (0);
}
Пример #3
0
quik_err_t
ext2fs_ls(char *dirname)
{
   ext2fs_node_t dirnode;
   quik_err_t err;

   if (ext2fs_root == NULL) {
      return ERR_FS_NOT_FOUND;
   }

   err = ext2fs_find_file(dirname, &ext2fs_root->diropen, &dirnode,
                          FILETYPE_DIRECTORY);
   if (err != ERR_NONE) {
      return err;
   }

   ext2fs_iterate_dir(dirnode, NULL, NULL, NULL);
   ext2fs_free_node(dirnode, &ext2fs_root->diropen);
   return ERR_NONE;
}
Пример #4
0
quik_err_t
ext2fs_open(char *filename,
            length_t *out_len)
{
   ext2fs_node_t fdiro = NULL;
   quik_err_t err;
   length_t len;

   if (ext2fs_root == NULL) {
      return ERR_FS_NOT_FOUND;
   }

   ext2fs_file = NULL;
   err = ext2fs_find_file(filename, &ext2fs_root->diropen, &fdiro,
                          FILETYPE_REG);
   if (err != ERR_NONE) {
      goto fail;
   }

   if (!fdiro->inode_read) {
      err = ext2fs_read_inode(fdiro->data, fdiro->ino,
                              &fdiro->inode);
      if (err != ERR_NONE) {
         goto fail;
      }
   }

   len = __le32_to_cpu(fdiro->inode.size);
   ext2fs_file = fdiro;
   *out_len = len;
   return ERR_NONE;

fail:
   ext2fs_free_node(fdiro, &ext2fs_root->diropen);
   return err;
}