Ejemplo n.º 1
0
int dir_partition_reiser_init(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const int verbose)
{
#ifdef HAVE_LIBREISERFS
  dal_t *dal;
  reiserfs_fs_t *fs;
  my_data_t *my_data;
  my_data=(my_data_t *)MALLOC(sizeof(*my_data));
  my_data->partition=partition;
  my_data->disk_car=disk_car;
  my_data->offset=0;
#ifdef HAVE_STRUCT_DAL_OPS_DEV
  dal=dal_open(&ops, "",DEFAULT_BLOCK_SIZE, O_RDONLY, my_data);
#else
  dal=dal_open(&ops, DEFAULT_BLOCK_SIZE, O_RDONLY, my_data);
#endif
  if (!dal)
  {
    log_error("Couldn't open device\n");
    free(my_data);
    return -1;
  }
  /* log_debug("file_open ok\n"); */

#ifdef HAVE_REISERFS_FS_OPEN_FAST
  if (!(fs = reiserfs_fs_open_fast(dal, dal)))
#else
    if (!(fs = reiserfs_fs_open(dal, dal)))
#endif
    {
      log_error("Couldn't open reiser filesystem %s\n",dal_error(dal));
      /* file_close call free(my_data) */
      file_close(dal);
      return -1;
    }
  /* log_debug("reiserfs_fs_open_fast ok\n"); */
  {
    struct rfs_dir_struct *ls=(struct rfs_dir_struct *)MALLOC(sizeof(*ls));
    ls->dir_list=NULL;
    ls->current_file=NULL;
    ls->current_fs=fs;
    ls->dal=dal;
    ls->flags = 0; /*DIRENT_FLAG_INCLUDE_EMPTY; */
    strncpy(dir_data->current_directory,"/",sizeof(dir_data->current_directory));
    dir_data->current_inode=2;
    dir_data->param=0;
    dir_data->verbose=verbose;
    dir_data->capabilities=0;
    dir_data->get_dir=reiser_dir;
    dir_data->copy_file=reiser_copy;
    dir_data->close=&dir_partition_reiser_close;
    dir_data->local_dir=NULL;
    dir_data->private_dir_data=ls;
  }
  return 0;
#else
  return -2;
#endif
}
Ejemplo n.º 2
0
/// open device
static void fs_open(char* device){

    if (!(dal = (dal_t*)file_dal_open(device, DEFAULT_BLOCK_SIZE, O_RDONLY))) {
        log_mesg(0, 1, 1, fs_opt.debug, "%s: Couldn't create device abstraction for %s.\n", __FILE__, device);
    }

    if (!(fs = reiserfs_fs_open(dal, dal))) {
        log_mesg(0, 1, 1, fs_opt.debug, "%s: Couldn't open filesystem on %s.\n", __FILE__, device);
    }

    if(fs_opt.ignore_fschk){
        log_mesg(1, 0, 0, fs_opt.debug, "%s: Ignore filesystem check\n", __FILE__);
    }else{
        if (get_sb_umount_state(fs->super) != FS_CLEAN)
            log_mesg(0, 1, 1, fs_opt.debug, "%s: Filesystem isn't in valid state. May be it is not cleanly unmounted.\n\n", __FILE__);
    }

}
Ejemplo n.º 3
0
static PedFileSystem *reiserfs_open(PedGeometry *geom)
{
	PedFileSystem *fs;
	PedGeometry *fs_geom;
	dal_t *dal;
	reiserfs_fs_t *fs_info;

	PED_ASSERT(geom != NULL);

	if (!(fs_geom = ped_geometry_duplicate(geom)))
		goto error;

	if (! (dal = geom_dal_create(fs_geom, DEFAULT_BLOCK_SIZE, O_RDONLY)))
		goto error_fs_geom_free;

	/*
	   We are passing NULL as DAL for journal. Therefore we let libreiserfs know,
	   that journal not available and parted will be working fine for reiserfs
	   with relocated journal too.
	 */
	if (!(fs = (PedFileSystem *) ped_malloc(sizeof(PedFileSystem))))
		goto error_free_dal;

	if (!(fs_info = reiserfs_fs_open(dal, NULL)))
		goto error_free_fs;

	fs->type = reiserfs_type;
	fs->geom = fs_geom;
	fs->type_specific = (void *) fs_info;

	return fs;

error_free_fs:
	free(fs);
error_free_dal:
	geom_dal_free(dal);
error_fs_geom_free:
	ped_geometry_destroy(fs_geom);
error:
	return NULL;
}