int DLL_DECL dpm_put (int nbreqfiles, struct dpm_putfilereq *reqfiles, int nbprotocols, char **protocols, char *u_token, int overwrite, time_t retrytime, char *r_token, int *nbreplies, struct dpm_putfilestatus **filestatuses) { int c; char errstring[256]; char func[16]; gid_t gid; int i; int msglen; char *rbp; char repbuf[4+256+CA_MAXDPMTOKENLEN+1]; char *sbp; char *sendbuf; char surl[CA_MAXSFNLEN+1]; struct dpm_api_thread_info *thip; uid_t uid; strcpy (func, "dpm_put"); if (dpm_apiinit (&thip)) return (-1); uid = geteuid(); gid = getegid(); #if defined(_WIN32) if (uid < 0 || gid < 0) { dpm_errmsg (func, DP053); serrno = SENOMAPFND; return (-1); } #endif if (nbreqfiles <= 0 || nbprotocols <= 0) { serrno = EINVAL; return (-1); } if (! reqfiles || ! protocols || ! r_token || ! nbreplies || ! filestatuses) { serrno = EFAULT; return (-1); } /* Compute size of send buffer */ msglen = 6 * LONGSIZE; for (i = 0; i < nbprotocols; i++) msglen += strlen (protocols[i]) + 1; if (u_token) msglen += strlen (u_token) + 1; else msglen++; msglen += LONGSIZE; msglen += TIME_TSIZE; msglen += LONGSIZE; for (i = 0; i < nbreqfiles; i++) { msglen += strlen ((reqfiles+i)->to_surl) + 1; msglen += TIME_TSIZE; msglen++; msglen += strlen ((reqfiles+i)->s_token) + 1; msglen += HYPERSIZE; msglen += TIME_TSIZE; msglen++; msglen++; } /* Allocate send buffer */ if ((sendbuf = malloc (msglen)) == NULL) { serrno = ENOMEM; return (-1); } /* Build request header */ sbp = sendbuf; marshall_LONG (sbp, DPM_MAGIC2); marshall_LONG (sbp, DPM_PUT); marshall_LONG (sbp, msglen); /* Build request body */ marshall_LONG (sbp, uid); marshall_LONG (sbp, gid); marshall_LONG (sbp, nbprotocols); for (i = 0; i < nbprotocols; i++) marshall_STRING (sbp, protocols[i]); if (u_token) { marshall_STRING (sbp, u_token); } else { marshall_STRING (sbp, ""); } marshall_LONG (sbp, overwrite); marshall_TIME_T (sbp, retrytime); marshall_LONG (sbp, nbreqfiles); for (i = 0; i < nbreqfiles; i++) { marshall_STRING (sbp, (reqfiles+i)->to_surl); marshall_TIME_T (sbp, (reqfiles+i)->lifetime); marshall_BYTE (sbp, (reqfiles+i)->f_type); marshall_STRING (sbp, (reqfiles+i)->s_token); marshall_HYPER (sbp, (reqfiles+i)->requested_size); marshall_TIME_T (sbp, (reqfiles+i)->f_lifetime); marshall_BYTE (sbp, (reqfiles+i)->ret_policy); marshall_BYTE (sbp, (reqfiles+i)->ac_latency); } c = send2dpm (NULL, sendbuf, msglen, repbuf, sizeof(repbuf), (void **)filestatuses, nbreplies); free (sendbuf); if (c == 0) { rbp = repbuf; unmarshall_LONG (rbp, c); if ((c & 0xF000) == DPM_FAILED) { serrno = c - DPM_FAILED; c = -1; } unmarshall_STRING (rbp, errstring); if (*errstring) dpm_errmsg (func, "%s\n", errstring); unmarshall_STRING (rbp, r_token); } return (c); }
int DLL_DECL Cns_setrtype(const char *sfn, const char type) { int c; char func[16]; gid_t gid; int msglen; char *q; char *sbp; char sendbuf[REQBUFSZ]; struct Cns_api_thread_info *thip; uid_t uid; u_signed64 zero = 0; strcpy (func, "Cns_setrtype"); if (Cns_apiinit (&thip)) return (-1); uid = getuid(); gid = getgid(); #if defined(_WIN32) if (uid < 0 || gid < 0) { Cns_errmsg (func, NS053); serrno = SENOMAPFND; return (-1); } #endif if (! sfn) { serrno = EFAULT; return (-1); } if (strlen (sfn) > CA_MAXSFNLEN) { serrno = ENAMETOOLONG; return (-1); } /* Build request header */ sbp = sendbuf; marshall_LONG (sbp, CNS_MAGIC); marshall_LONG (sbp, CNS_SETRTYPE); q = sbp; /* save pointer. The next field will be updated */ msglen = 3 * LONGSIZE; marshall_LONG (sbp, msglen); /* Build request body */ marshall_LONG (sbp, uid); marshall_LONG (sbp, gid); marshall_STRING (sbp, sfn); marshall_BYTE (sbp, type); msglen = sbp - sendbuf; marshall_LONG (q, msglen); /* update length field */ c = send2nsd (NULL, NULL, sendbuf, msglen, NULL, 0); if (c && serrno == SENAMETOOLONG) serrno = ENAMETOOLONG; return (c); }
int DLL_DECL Cns_setacl(const char *path, int nentries, struct Cns_acl *acl) { char *actual_path; int c; char func[16]; gid_t gid; int i; int msglen; char *q; char *sbp; char sendbuf[REQBUFSZ]; char server[CA_MAXHOSTNAMELEN+1]; struct Cns_api_thread_info *thip; uid_t uid; strcpy (func, "Cns_setacl"); if (Cns_apiinit (&thip)) return (-1); uid = getuid(); gid = getgid(); #if defined(_WIN32) if (uid < 0 || gid < 0) { Cns_errmsg (func, NS053); serrno = SENOMAPFND; return (-1); } #endif if (! path || ! acl) { serrno = EFAULT; return (-1); } if (strlen (path) > CA_MAXPATHLEN) { serrno = ENAMETOOLONG; return (-1); } if (nentries <= 0 || nentries > CA_MAXACLENTRIES) { serrno = EINVAL; return (-1); } if (Cns_selectsrvr (path, thip->server, server, &actual_path)) return (-1); /* Build request header */ sbp = sendbuf; marshall_LONG (sbp, CNS_MAGIC); marshall_LONG (sbp, CNS_SETACL); q = sbp; /* save pointer. The next field will be updated */ msglen = 3 * LONGSIZE; marshall_LONG (sbp, msglen); /* Build request body */ marshall_LONG (sbp, uid); marshall_LONG (sbp, gid); marshall_HYPER (sbp, thip->cwd); marshall_STRING (sbp, actual_path); marshall_WORD (sbp, nentries); for (i = 0; i < nentries; i++) { marshall_BYTE (sbp, acl->a_type); marshall_LONG (sbp, acl->a_id); marshall_BYTE (sbp, acl->a_perm); acl++; } msglen = sbp - sendbuf; marshall_LONG (q, msglen); /* update length field */ c = send2nsd (NULL, server, sendbuf, msglen, NULL, 0); if (c && serrno == SENAMETOOLONG) serrno = ENAMETOOLONG; return (c); }
void lwesrb_dump_type(LWES_BYTE type, LWES_BYTE_P buf, size_t *off) { if (marshall_BYTE(type, buf, MAX_MSG_SIZE, off) > 0) return; rb_raise(rb_eRuntimeError, "failed to dump type=%02x", (unsigned)type); }
int DLL_DECL dpm_modifypool(struct dpm_pool *dpm_pool) { int c; char func[16]; gid_t gid; int i; int msglen; char *p; char *q; char *sbp; char sendbuf[REQBUFSZ]; struct dpm_api_thread_info *thip; uid_t uid; strcpy (func, "dpm_modifypool"); if (dpm_apiinit (&thip)) return (-1); uid = geteuid(); gid = getegid(); #if defined(_WIN32) if (uid < 0 || gid < 0) { dpm_errmsg (func, DP053); serrno = SENOMAPFND; return (-1); } #endif if (! dpm_pool) { serrno = EFAULT; return (-1); } /* Build request header */ sbp = sendbuf; marshall_LONG (sbp, DPM_MAGIC3); marshall_LONG (sbp, DPM_MODPOOL); q = sbp; /* save pointer. The next field will be updated */ msglen = 3 * LONGSIZE; marshall_LONG (sbp, msglen); /* Build request body */ marshall_LONG (sbp, uid); marshall_LONG (sbp, gid); marshall_STRING (sbp, dpm_pool->poolname); marshall_HYPER (sbp, dpm_pool->defsize); marshall_LONG (sbp, dpm_pool->gc_start_thresh); marshall_LONG (sbp, dpm_pool->gc_stop_thresh); marshall_LONG (sbp, dpm_pool->defpintime); marshall_STRING (sbp, dpm_pool->fss_policy); marshall_STRING (sbp, dpm_pool->gc_policy); marshall_STRING (sbp, dpm_pool->rs_policy); marshall_LONG (sbp, dpm_pool->nbgids > 0 ? dpm_pool->gids[0] : -1); marshall_BYTE (sbp, dpm_pool->s_type); marshall_STRING (sbp, dpm_pool->mig_policy); marshall_BYTE (sbp, dpm_pool->ret_policy); marshall_LONG (sbp, dpm_pool->def_lifetime); marshall_LONG (sbp, dpm_pool->max_lifetime); marshall_LONG (sbp, dpm_pool->maxpintime); marshall_LONG (sbp, dpm_pool->nbgids); for (i = 0; i < dpm_pool->nbgids; i++) marshall_LONG (sbp, dpm_pool->gids[i]); msglen = sbp - sendbuf; marshall_LONG (q, msglen); /* update length field */ c = send2dpm (NULL, sendbuf, msglen, NULL, 0, NULL, NULL); return (c); }
int DLL_DECL Cns_modreplicax(const char *sfn, const char *setname, const char *poolname, const char *server, const char *fs, const char r_type) { int c; int extended = 0; char func[16]; gid_t gid; int msglen; char *q; char *sbp; char sendbuf[REQBUFSZ]; struct Cns_api_thread_info *thip; uid_t uid; u_signed64 zero = 0; strcpy (func, "Cns_modreplica"); if (Cns_apiinit (&thip)) return (-1); uid = getuid(); gid = getgid(); #if defined(_WIN32) if (uid < 0 || gid < 0) { Cns_errmsg (func, NS053); serrno = SENOMAPFND; return (-1); } #endif if (! sfn) { serrno = EFAULT; return (-1); } if (strlen (sfn) > CA_MAXSFNLEN) { serrno = ENAMETOOLONG; return (-1); } if ((setname && strlen (setname) > 36) || (poolname && strlen (poolname) > CA_MAXPOOLNAMELEN) || (server && strlen (server) > CA_MAXHOSTNAMELEN)) { serrno = EINVAL; return (-1); } /* Build request header */ if (r_type || (fs && strlen (fs) > 0)) extended = 1; sbp = sendbuf; marshall_LONG (sbp, CNS_MAGIC); marshall_LONG (sbp, (extended ? CNS_MODREPLICAX : CNS_MODREPLICA)); q = sbp; /* save pointer. The next field will be updated */ msglen = 3 * LONGSIZE; marshall_LONG (sbp, msglen); /* Build request body */ marshall_LONG (sbp, uid); marshall_LONG (sbp, gid); marshall_STRING (sbp, sfn); if (setname) { marshall_STRING (sbp, setname); } else { marshall_STRING (sbp, ""); } if (poolname) { marshall_STRING (sbp, poolname); } else { marshall_STRING (sbp, ""); } if (server) { marshall_STRING (sbp, server); } else { marshall_STRING (sbp, ""); } if (extended) { if (fs) { marshall_STRING (sbp, fs); } else { marshall_STRING (sbp, ""); } marshall_BYTE (sbp, r_type); } msglen = sbp - sendbuf; marshall_LONG (q, msglen); /* update length field */ c = send2nsd (NULL, NULL, sendbuf, msglen, NULL, 0); if (c && serrno == SENAMETOOLONG) serrno = ENAMETOOLONG; return (c); }