Functions

dsi_write.c File Reference

#include <fcntl.h>
#include "grpc.h"
Include dependency graph for dsi_write.c:

Go to the source code of this file.

Functions

int grpc_dsi_ibp_store (DSI_FILE *dsi_file, char *data, int length)
int grpc_dsi_store (DSI_FILE *dsi_file, char *data, int length)
grpc_error_t grpc_dsi_write_vector (DSI_OBJECT **robject, DSI_FILE *dsi_file, void *data, int count, enum datatype data_type)
grpc_error_t grpc_dsi_write_matrix (DSI_OBJECT **robject, DSI_FILE *dsi_file, void *data, int rows, int cols, enum datatype data_type)

Function Documentation

int grpc_dsi_ibp_store ( DSI_FILE *  dsi_file,
char *  data,
int  length 
)

Definition at line 8 of file dsi_write.c.

{
#ifdef DSI_IBP
  struct ibp_timer t;
  IBP_cap wcap;

  t.ServerSync = 10;
  t.ClientTimeout = 10;

  wcap = dsi_file->dsi_specifics.ibp.cap->writeCap;

  if(IBP_store(wcap, &t, data, length) < 0) {
    ERRPRINTF("IBP_store failed\n");
    return -1;
  }

  return 0;
#else
  return -1;
#endif
}

Here is the caller graph for this function:

int grpc_dsi_store ( DSI_FILE *  dsi_file,
char *  data,
int  length 
)

Definition at line 31 of file dsi_write.c.

{
  if(dsi_file->storage_system == GS_DSI_IBP) {
#ifdef DSI_IBP
    return grpc_dsi_ibp_store(dsi_file, data, length);
#endif
  }

  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

grpc_error_t grpc_dsi_write_matrix ( DSI_OBJECT **  robject,
DSI_FILE *  dsi_file,
void *  data,
int  rows,
int  cols,
enum datatype  data_type 
)

Definition at line 90 of file dsi_write.c.

{
  return grpc_dsi_write_vector(robject, dsi_file, data, rows*cols, data_type);
}

Here is the call graph for this function:

grpc_error_t grpc_dsi_write_vector ( DSI_OBJECT **  robject,
DSI_FILE *  dsi_file,
void *  data,
int  count,
enum datatype  data_type 
)

Definition at line 43 of file dsi_write.c.

{
#ifdef DSI
  int write_allowed;
  int perm;
  int extent, length;
  uid_t my_uid;
  DSI_OBJECT* dsi_obj;
  int my_dsig;

  my_dsig = pvmgetdsig();
  extent = gs_get_element_size(data_type, my_dsig);
  length = count*extent;

  my_uid = getuid();

  if(my_uid == dsi_file->uid)
    perm = dsi_file->perm / 100;
  else
    perm = dsi_file->perm % 10;

  write_allowed = perm & 2;

  if(write_allowed && ((dsi_file->flag&O_WRONLY) || (dsi_file->flag&O_RDWR))) {
    if(grpc_dsi_store(dsi_file, data, length) < 0)
      GRPC_RETURN(GRPC_OTHER_ERROR_CODE, GRPC_DSI_STORE_ERROR);

    dsi_obj = (DSI_OBJECT*)malloc(sizeof(DSI_OBJECT));
    dsi_obj->offset = dsi_file->written_count;
    dsi_obj->dsi_file = dsi_file;
    dsi_file->written_count += length;

    if(gs_insert_dsi_object(dsi_obj) < 0)
      GRPC_RETURN(GRPC_OTHER_ERROR_CODE, GRPC_DSI_INTERNAL_ERROR);

    *robject = dsi_obj;
    GRPC_RETURN(GRPC_NO_ERROR, GRPC_NO_MINOR_ERROR);
  }
  else
    GRPC_RETURN(GRPC_OTHER_ERROR_CODE, GRPC_DSI_EACCES);
#endif

  GRPC_RETURN(GRPC_OTHER_ERROR_CODE, GRPC_DSI_DISABLED);
}

Here is the call graph for this function:

Here is the caller graph for this function: