diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2012-06-06 21:38:06 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2012-06-06 21:38:06 (GMT) |
commit | 6d5505282c353aeeae1c5bd4420607cd7489c996 (patch) | |
tree | a3836814f1db688e841c1a06608d284fc3698815 /src | |
parent | f38d9a2149d189fa82b5b5d491f7ed10feffc900 (diff) | |
download | hdf5-6d5505282c353aeeae1c5bd4420607cd7489c996.zip hdf5-6d5505282c353aeeae1c5bd4420607cd7489c996.tar.gz hdf5-6d5505282c353aeeae1c5bd4420607cd7489c996.tar.bz2 |
[svn-r22439] file image and mount operations handled in VOL
Diffstat (limited to 'src')
-rw-r--r-- | src/H5F.c | 45 | ||||
-rw-r--r-- | src/H5Fmount.c | 32 | ||||
-rw-r--r-- | src/H5Fpkg.h | 2 | ||||
-rw-r--r-- | src/H5Fprivate.h | 2 | ||||
-rw-r--r-- | src/H5VLnative.c | 49 | ||||
-rw-r--r-- | src/H5VLpublic.h | 27 |
6 files changed, 122 insertions, 35 deletions
@@ -2615,17 +2615,48 @@ done: ssize_t H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) { - H5F_t *file; /* File object for file ID */ - H5FD_t *fd_ptr; /* file driver */ - haddr_t eoa; /* End of file address */ ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*xz", file_id, buf_ptr, buf_len); + /* check id */ + if(H5I_FILE != H5I_get_type(file_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + + /* get image through the VOL */ + if(H5VL_file_optional(file_id, H5VL_FILE_GET_FILE_IMAGE, H5_REQUEST_NULL, + buf_ptr, &ret_value, buf_len) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file image") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Fget_file_image() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_file_image + * + * Purpose: Private version of H5Fget_file_image + * + * Return: Success: Bytes copied / number of bytes needed. + * Failure: negative value + * + * Programmer: John Mainzer + * 11/15/11 + * + *------------------------------------------------------------------------- + */ +ssize_t +H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) +{ + H5FD_t *fd_ptr; /* file driver */ + haddr_t eoa; /* End of file address */ + ssize_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") if(!file || !file->shared || !file->shared->lf) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file_id yields invalid file pointer") fd_ptr = file->shared->lf; @@ -2700,8 +2731,8 @@ H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) } /* end if */ done: - FUNC_LEAVE_API(ret_value) -} /* H5Fget_file_image() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F_get_file_image() */ /*------------------------------------------------------------------------- diff --git a/src/H5Fmount.c b/src/H5Fmount.c index ee7af97..18dd601 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -28,11 +28,9 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ #include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* VOL plugins */ /* PRIVATE PROTOTYPES */ -static herr_t H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, - hid_t plist_id, hid_t dxpl_id); -static herr_t H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id); static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); @@ -126,7 +124,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t UNUSED plist_id, hid_t dxpl_id) { @@ -292,7 +290,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id) { H5G_t *child_group = NULL; /* Child's group in parent mtab */ @@ -470,28 +468,33 @@ H5F_is_mount(const H5F_t *file) herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { - H5G_loc_t loc; - H5F_t *child = NULL; + H5VL_class_t *vol_plugin1; /* VOL structure attached to loc_id */ + H5VL_class_t *vol_plugin2; /* VOL structure attached to child_id */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") if(H5P_DEFAULT == plist_id) plist_id = H5P_FILE_MOUNT_DEFAULT; else if(TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") - /* Do the mount */ - if(H5F_mount(&loc, name, child, plist_id, H5AC_dxpl_id) < 0) + if (NULL == (vol_plugin1 = (H5VL_class_t *)H5I_get_aux(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id does not contain VOL information") + if (NULL == (vol_plugin2 = (H5VL_class_t *)H5I_get_aux(child_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id does not contain VOL information") + + /* check if both objects are associated with the same VOL plugin */ + if (vol_plugin1 != vol_plugin2) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL plugin") + + if((ret_value = H5VL_file_misc(loc_id, H5VL_FILE_MOUNT, H5_REQUEST_NULL, + name, child_id, plist_id)) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: @@ -533,8 +536,7 @@ H5Funmount(hid_t loc_id, const char *name) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Unmount */ - if (H5F_unmount(&loc, name, H5AC_dxpl_id) < 0) + if((ret_value = H5VL_file_misc(loc_id, H5VL_FILE_UNMOUNT, H5_REQUEST_NULL, name)) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index bdc01a6..a3c7854 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -302,6 +302,8 @@ H5_DLL haddr_t H5F_locate_signature(H5FD_t *file, hid_t dxpl_id); H5_DLL herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, hbool_t closing); /* File mount related routines */ +H5_DLL herr_t H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id, hid_t dxpl_id); +H5_DLL herr_t H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id); H5_DLL herr_t H5F_close_mounts(H5F_t *f); H5_DLL int H5F_term_unmount_cb(void *obj_ptr, hid_t obj_id, void *key); H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index fdbd0b6..20aff87 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -28,7 +28,6 @@ /* Private headers needed by this file */ - /****************************/ /* Library Private Typedefs */ /****************************/ @@ -528,6 +527,7 @@ H5_DLL unsigned H5F_get_nopen_objs(const H5F_t *f); H5_DLL unsigned H5F_incr_nopen_objs(H5F_t *f); H5_DLL unsigned H5F_decr_nopen_objs(H5F_t *f); H5_DLL hid_t H5F_get_file_id(const H5F_t *f); +H5_DLL ssize_t H5F_get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len); H5_DLL H5F_t *H5F_get_parent(const H5F_t *f); H5_DLL unsigned H5F_get_nmounts(const H5F_t *f); H5_DLL hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref); diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 24b8947..1ef7b09 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -1678,6 +1678,43 @@ H5VL_native_file_misc(hid_t loc_id, H5VL_file_misc_t misc_type, hid_t UNUSED req HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't determine if file is an HDF5 file") break; } + /* H5Fmount */ + case H5VL_FILE_MOUNT: + { + const char *name = va_arg (arguments, const char *); + hid_t child_id = va_arg (arguments, hid_t); + hid_t plist_id = va_arg (arguments, hid_t); + H5G_loc_t loc; + H5F_t *child = NULL; + + /* Check arguments */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + + /* Do the mount */ + if(H5F_mount(&loc, name, child, plist_id, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + + break; + } + /* H5Fmount */ + case H5VL_FILE_UNMOUNT: + { + const char *name = va_arg (arguments, const char *); + H5G_loc_t loc; + + /* Check arguments */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Unmount */ + if (H5F_unmount(&loc, name, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") } @@ -1734,6 +1771,18 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN *ret = (hsize_t)eof; break; } + /* H5Fget_file_image */ + case H5VL_FILE_GET_FILE_IMAGE: + { + void *buf_ptr = va_arg (arguments, void *); + ssize_t *ret = va_arg (arguments, ssize_t *); + size_t buf_len = va_arg (arguments, size_t ); + + /* Do the actual work */ + if((*ret = H5F_get_file_image(f, buf_ptr, buf_len)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") + break; + } /* H5Fget_freespace */ case H5VL_FILE_GET_FREE_SPACE: { diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index d0ee1aa..388debc 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -81,23 +81,26 @@ typedef enum H5VL_file_get_t { /* types for all file misc operations */ typedef enum H5VL_file_misc_t { - H5VL_FILE_IS_HDF5 = 0 /* is HDF5? */ + H5VL_FILE_IS_HDF5 = 0, /* is HDF5? */ + H5VL_FILE_MOUNT = 1, + H5VL_FILE_UNMOUNT = 2 } H5VL_file_misc_t; /* types for all file optional operations */ typedef enum H5VL_file_optional_t { H5VL_FILE_CLEAR_ELINK_CACHE = 0, - H5VL_FILE_GET_FREE_SECTIONS = 1, /*file free selections */ - H5VL_FILE_GET_FREE_SPACE = 2, /*file freespace */ - H5VL_FILE_GET_INFO = 3, /*file info */ - H5VL_FILE_GET_MDC_CONF = 4, /*file metadata cache configuration */ - H5VL_FILE_GET_MDC_HR = 5, /*file metadata cache hit rate */ - H5VL_FILE_GET_MDC_SIZE = 6, /*file metadata cache size */ - H5VL_FILE_GET_SIZE = 7, /*file size */ - H5VL_FILE_GET_VFD_HANDLE = 8, /*file VFD handle */ - H5VL_FILE_REOPEN = 9, - H5VL_FILE_RESET_MDC_HIT_RATE = 10, - H5VL_FILE_SET_MDC_CONFIG = 11 + H5VL_FILE_GET_FILE_IMAGE = 1, /*file image */ + H5VL_FILE_GET_FREE_SECTIONS = 2, /*file free selections */ + H5VL_FILE_GET_FREE_SPACE = 3, /*file freespace */ + H5VL_FILE_GET_INFO = 4, /*file info */ + H5VL_FILE_GET_MDC_CONF = 5, /*file metadata cache configuration */ + H5VL_FILE_GET_MDC_HR = 6, /*file metadata cache hit rate */ + H5VL_FILE_GET_MDC_SIZE = 7, /*file metadata cache size */ + H5VL_FILE_GET_SIZE = 8, /*file size */ + H5VL_FILE_GET_VFD_HANDLE = 9, /*file VFD handle */ + H5VL_FILE_REOPEN = 10, + H5VL_FILE_RESET_MDC_HIT_RATE = 11, + H5VL_FILE_SET_MDC_CONFIG = 12 } H5VL_file_optional_t; /* types for all group get API routines */ |