示例#1
0
文件: rmtsyss.c 项目: bagdxk/openafs
/* Implements the remote setpag(2) call. Note that unlike the standard call,
 * here we also get back the new pag value; we need this so that the caller
 * can add it to its group list via setgroups() */
afs_int32
SRMTSYS_SetPag(struct rx_call *call, clientcred *creds, afs_int32 *newpag,
	       afs_int32 *errornumber)
{
    afs_uint32 blob[PIOCTL_HEADER];
    struct ViceIoctl data;
    afs_int32 error;

    *errornumber = 0;
    SETCLIENTCONTEXT(blob, rx_HostOf(rx_PeerOf(rx_ConnectionOf(call))), creds->uid,
		     creds->group0, creds->group1, PSETPAG, NFS_EXPORTER);
    data.in = (caddr_t) blob;
    data.in_size = sizeof(blob);
    data.out = (caddr_t) blob;
    data.out_size = sizeof(blob);
    /* force local pioctl call */
    error = lpioctl(0, _VICEIOCTL(PSetClientContext), &data, 1);
    if (error) {
	if (errno == PSETPAG) {
	    *newpag = blob[0];	/* new pag value */
	} else
	    *errornumber = errno;
    }
    return 0;
}
示例#2
0
int
GetInitParamsCmd(struct cmd_syndesc *as, void *arock)
{
    struct cm_initparams cm_initParams;
    struct ViceIoctl blob;
    int code;
    int len;
    char *file = 0;
    int fd = 0;

    if (as->parms[0].items) {
	file = as->parms[0].items->data;
    }

    if (file) {
	printf("ioctl test\n");
	fd = open(file, O_RDONLY, 0);
	if (fd < 0) {
	    perror("open");
	    exit(1);
	}
    } else {
	printf("lpioctl test\n");
    }

    blob.in = (char *)0;
    blob.in_size = 0;
    blob.out = (char *)&cm_initParams;
    blob.out_size = sizeof(struct cm_initparams);

    if (file) {
	code = ioctl(fd, VIOC_GETINITPARAMS, &blob);
	if (code < 0) {
	    perror("ioctl: Error getting CM initialization parameters");
	    exit(1);
	}
	close(fd);
    } else {
	code = lpioctl(NULL, VIOC_GETINITPARAMS, &blob, 0);
	if (code) {
	    perror("lpioctl: Error getting CM initialization parameters");
	    exit(1);
	}
    }

    printf("cm_initparams version: %d\n", cm_initParams.cmi_version);
    printf("Chunk Files: %d\n", cm_initParams.cmi_nChunkFiles);
    printf("Stat Caches: %d\n", cm_initParams.cmi_nStatCaches);
    printf("Data Caches: %d\n", cm_initParams.cmi_nDataCaches);
    printf("Volume Caches: %d\n", cm_initParams.cmi_nVolumeCaches);
    printf("First Chunk Size: %d\n", cm_initParams.cmi_firstChunkSize);
    printf("Other Chunk Size: %d\n", cm_initParams.cmi_otherChunkSize);
    printf("Initial Cache Size: %dK\n", cm_initParams.cmi_cacheSize);
    printf("CM Sets Time: %c\n", cm_initParams.cmi_setTime ? 'Y' : 'N');
    printf("Disk Based Cache: %c\n", cm_initParams.cmi_memCache ? 'N' : 'Y');

    exit(0);
}
示例#3
0
/* Implements the remote pioctl(2) call */
afs_int32
SRMTSYS_Pioctl(struct rx_call *call, clientcred *creds, char *path,
	       afs_int32 cmd, afs_int32 follow, rmtbulk *InData,
	       rmtbulk *OutData, afs_int32 *errornumber)
{
    afs_int32 error;
    struct ViceIoctl data;
    char *pathp = path;
    afs_uint32 blob[PIOCTL_HEADER];

    *errornumber = 0;
    SETCLIENTCONTEXT(blob, rx_HostOf(call->conn->peer), creds->uid,
		     creds->group0, creds->group1, cmd, NFS_EXPORTER);
    data.in =
	(char *)malloc(InData->rmtbulk_len +
		       PIOCTL_HEADER * sizeof(afs_int32));
    if (!data.in)
	return (-1);		/* helpless here */
    if (!strcmp(path, NIL_PATHP))
	pathp = (char *)0;	/* It meant to be NIL */
    memcpy(data.in, blob, sizeof(blob));
    inparam_conversion(cmd, InData->rmtbulk_val, 1);
    memcpy(data.in + sizeof(blob), InData->rmtbulk_val, InData->rmtbulk_len);
    data.in_size = InData->rmtbulk_len + PIOCTL_HEADER * sizeof(afs_int32);
    data.out = OutData->rmtbulk_val;
    data.out_size = OutData->rmtbulk_len;
    /* force local pioctl call */
    error = lpioctl(pathp, _VICEIOCTL(PSetClientContext), &data, follow);
    if (error) {
	*errornumber = errno;
    } else {
	/* Send the results back in network order */
	outparam_conversion(cmd, data.out, 0);
    }
    free(data.in);
    /* Note that we return success (i.e. 0) even when pioctl fails; that's
     * because the actual errno is passed back via 'errornumber' and this call
     * MUST return success error in order to get that OUT params back (YUCK!)
     */
    return (0);
}