Go to the documentation of this file.00001 #include <stdio.h>
00002 #include <fcntl.h>
00003
00004 #ifdef HAVE_CONFIG_H
00005 #include "config.h"
00006 #endif
00007
00008 #include "grpc.h"
00009
00010 grpc_error_t
00011 grpc_dsi_read_vector(DSI_OBJECT *dsi_obj, void *data,
00012 int count, enum datatype data_type, int *bytes_read)
00013 {
00014 #ifdef DSI
00015 int read_allowed;
00016 int perm;
00017 int offset, extent, length;
00018 int my_dsig;
00019 uid_t my_uid;
00020
00021 #ifdef DSI_IBP
00022 struct ibp_timer ls_timeout;
00023 #endif
00024
00025 my_dsig = pvmgetdsig();
00026 extent = gs_get_element_size(data_type, my_dsig);
00027 length = count*extent;
00028
00029 my_uid = getuid();
00030
00031 if(my_uid == dsi_obj->dsi_file->uid)
00032 perm = dsi_obj->dsi_file->perm / 100;
00033 else
00034 perm = dsi_obj->dsi_file->perm % 10;
00035
00036 read_allowed = perm & 4;
00037
00038 if(read_allowed && ((dsi_obj->dsi_file->flag&O_RDONLY) ||
00039 (dsi_obj->dsi_file->flag&O_RDWR))) {
00040
00041 offset = dsi_obj->offset;
00042
00043 if(dsi_obj->dsi_file->storage_system == GS_DSI_IBP) {
00044 #ifdef DSI_IBP
00045 int return_value;
00046
00047 ls_timeout.ServerSync = 10;
00048 ls_timeout.ClientTimeout = 10;
00049
00050 return_value =
00051 IBP_load(dsi_obj->dsi_file->dsi_specifics.ibp.cap->readCap,
00052 &ls_timeout, data, length, offset);
00053 if(return_value == 0)
00054 GRPC_RETURN(GRPC_OTHER_ERROR_CODE, GRPC_DSI_LOAD_ERROR);
00055
00056 *bytes_read = return_value/extent;
00057
00058 GRPC_RETURN(GRPC_NO_ERROR, GRPC_NO_MINOR_ERROR);
00059 #endif
00060 }
00061 }
00062 else
00063 GRPC_RETURN(GRPC_OTHER_ERROR_CODE, GRPC_DSI_EACCES);
00064
00065 *bytes_read = 0;
00066 GRPC_RETURN(GRPC_NO_ERROR, GRPC_NO_MINOR_ERROR);
00067 #endif
00068
00069 GRPC_RETURN(GRPC_OTHER_ERROR_CODE, GRPC_DSI_DISABLED);
00070 }
00071
00072 grpc_error_t
00073 grpc_dsi_read_matrix(DSI_OBJECT *dsi_obj, void *data,
00074 int rows, int cols, enum datatype data_type, int *bytes_read)
00075 {
00076 return grpc_dsi_read_vector(dsi_obj, data, rows*cols, data_type, bytes_read);
00077 }