Beispiel #1
0
PyObject* dsmRegisterFS_wrapper(PyObject * self, PyObject * args) {
    dsUint32_t dsmHandle;
    regFSData regfsdata;
    int rc = 0;
    PyObject* fsData = NULL;
    /*
     * Example dict:
     * {'fsName':'/my/path','fsType':'some_type','occupancy':1024, 'capacity':4096, 'fsAttr':{
     *      'netwareFSAttr': {'fsInfoLength':9,'fsInfo':'rwxrwxrwx'},
     *      'unixFSAttr':{'fsInfoLength':9, 'fsInfo':'rwxrwxrwx'},
     *      'dosFSAttr':{'driveLetter':'', 'fsInfoLength':0, 'fsInfo':''}}
     * }
    */
    memset(&regfsdata,0x00,sizeof(regFSData));

    if (!PyArg_ParseTuple(args, "IO", &dsmHandle, &fsData)) {
        return NULL;
    }
    pyDictToRegFSData(fsData, &regfsdata);

    rc = dsmRegisterFS(dsmHandle, &regfsdata);

    return Py_BuildValue("I", rc);
}
Beispiel #2
0
int
tsminit(char *fs, int restore)
{
	regFSData	regFS;
	dsmApiVersionEx	apiLibVer, apiApplVer;
	dsmInitExIn_t	initIn;
	dsmInitExOut_t	initOut;
	dsInt16_t	rv, appVersion, libVersion;
	ApiSessInfo	apis;

	memset(&apiLibVer, 0, sizeof(apiLibVer));
	dsmQueryApiVersionEx(&apiLibVer);

	appVersion = (10000 * DSM_API_VERSION)+(1000 * DSM_API_RELEASE) +
		(100 * DSM_API_LEVEL) + DSM_API_SUBLEVEL;

	libVersion = (apiLibVer.version * 10000) + (apiLibVer.release * 1000) +
	    (apiLibVer.level * 100) + (apiLibVer.subLevel);

	if (libVersion < appVersion)
		errx(1, "libVersion (%x) < appVersion (%x)",
		    libVersion, appVersion);

	memset(&initIn, 0, sizeof(dsmInitExIn_t));
	memset(&initOut, 0, sizeof(dsmInitExOut_t));
	memset(&apiApplVer, 0, sizeof(dsmApiVersionEx));
	apiApplVer.version = DSM_API_VERSION;
	apiApplVer.release = DSM_API_RELEASE;
	apiApplVer.level = DSM_API_LEVEL;
	apiApplVer.subLevel = DSM_API_SUBLEVEL;


	initIn.stVersion = dsmInitExInVersion;
	initIn.apiVersionExP = &apiApplVer;
	initIn.clientNodeNameP = NULL;
	initIn.clientOwnerNameP = NULL;
	initIn.clientPasswordP = NULL;
	initIn.applicationTypeP = "OpenAFS";
	initIn.configfile = NULL;
	initIn.options = NULL;
	initIn.userNameP = NULL;
	initIn.userPasswordP = NULL;

	rv = dsmInitEx(&dsmHandle, &initIn, &initOut);
	if (rv != 0) {
		if (rv == DSM_RC_REJECT_VERIFIER_EXPIRED)
			errx(1, "TSM password expired");
		else
			tsmerror("dsmInitEx failed", rv);
		return rv;
	}

	memset(&apis, 0, sizeof(ApiSessInfo));
	apis.stVersion = ApiSessInfoVersion;
	if ((rv = dsmQuerySessInfo(dsmHandle, &apis)) == DSM_RC_OK)
		maxobjtxn = apis.maxObjPerTxn;

	if (rv != 0) {
		tsmerror("dsmQuerySessInfo failed", rv);
		return rv;
	}

        if (restore == 0) {
		memset(&regFS, 0, sizeof(regFS));
		regFS.fsName = fs;
		regFS.fsType = "OpenAFS";
		if ((rv = dsmRegisterFS(dsmHandle, &regFS)) != DSM_RC_OK &&
		    rv != DSM_RC_FS_ALREADY_REGED)
			tsmerror("dsmRegisterFS", rv);
		if (rv == DSM_RC_FS_ALREADY_REGED) {
			TADEBUG("filespace %s already registered\n", fs);
			rv = 0;
		} else
			TADEBUG("filespace %s registered\n", fs);
	}
	return rv;
}