コード例 #1
0
ファイル: vptab.c プロジェクト: chanke/openafs-osd
/*
 * vpt_RemoveEntry() -- Remove vice partition table entry.
 *
 * RETURN CODES: 0 success, -1 failed (errno set)
 */
int
vpt_RemoveEntry(const char *vpname)
{
    long status;
    HKEY tabKey;

    if (!vpt_PartitionNameValid(vpname)) {
	errno = EINVAL;
	return -1;
    }

    /* open canonical Afstab key */
    status = RegOpenKeyAlt(AFSREG_NULL_KEY, AFSREG_SVR_SVC_AFSTAB_KEY,
			   KEY_WRITE, 0, &tabKey, NULL);

    if (status == ERROR_SUCCESS) {
	/* delete key representing vice partition */
	status = RegDeleteKey(tabKey, vpname);
    }

    if (status) {
	errno = nterr_nt2unix(status, EIO);
	return -1;
    }
    return 0;
}
コード例 #2
0
ファイル: cfghost.c プロジェクト: maxendpoint/openafs_cvs
/*
 * cfg_HostPartitionTableRemoveEntry() -- Remove AFS partition table entry.
 */
int ADMINAPI
cfg_HostPartitionTableRemoveEntry(void *hostHandle,	/* host config handle */
				  const char *partName,	/* partition name */
				  afs_status_p st)
{				/* completion status */
    int rc = 1;
    afs_status_t tst2, tst = 0;
    cfg_host_p cfg_host = (cfg_host_p) hostHandle;

#ifdef AFS_NT40_ENV
    /* validate parameters */

    if (!cfgutil_HostHandleValidate(cfg_host, &tst2)) {
	tst = tst2;
    } else if (partName == NULL) {
	tst = ADMCFGPARTITIONNAMENULL;
    } else if (!vpt_PartitionNameValid(partName)) {
	tst = ADMCFGPARTITIONNAMEBAD;
    }

    /* remote configuration not yet supported in this function */

    if (tst == 0) {
	if (!cfg_host->is_local) {
	    tst = ADMCFGNOTSUPPORTED;
	}
    }

    /* remove entry from table */

    if (tst == 0) {
	if (vpt_RemoveEntry(partName)) {
	    /* ENOENT implies entry does not exist; consider to be removed */
	    if (errno != ENOENT) {
		if (errno == EACCES) {
		    tst = ADMNOPRIV;
		} else if (errno == EINVAL) {
		    /* shouldn't happen since checked partition/dev names */
		    tst = ADMCFGPARTITIONNAMEBAD;
		} else {
		    tst = ADMCFGVPTABLEWRITEFAILED;
		}
	    }
	}
    }
#else
    /* function not yet implemented for unix */
    if (tst == 0) {
	tst = ADMCFGNOTSUPPORTED;
    }
#endif /* AFS_NT40_ENV */

    if (tst != 0) {
	rc = 0;
    }
    if (st != NULL) {
	*st = tst;
    }
    return rc;
}
コード例 #3
0
ファイル: vptab.c プロジェクト: chanke/openafs-osd
/*
 * vpt_AddEntry() -- Add or update vice partition table entry.
 *
 * RETURN CODES: 0 success, -1 failed (errno set)
 */
int
vpt_AddEntry(const struct vptab *vptabp)
{
    long status;
    HKEY tabKey, vpKey;
    const char *vpName, *vpDev;

    vpName = vptabp->vp_name;
    vpDev = vptabp->vp_dev;

    if (!vpt_PartitionNameValid(vpName) || !vpt_DeviceNameValid(vpDev)) {
	errno = EINVAL;
	return -1;
    }

    /* open canonical Afstab key; create if doesn't exist */
    status = RegOpenKeyAlt(AFSREG_NULL_KEY, AFSREG_SVR_SVC_AFSTAB_KEY,
			   KEY_WRITE, 1 /* create */, &tabKey, NULL);

    if (status == ERROR_SUCCESS) {
	/* open key representing vice partition; create if doesn't exist */
	status = RegOpenKeyAlt(tabKey, vpName,
			       KEY_WRITE, 1 /* create */, &vpKey, NULL);

	if (status == ERROR_SUCCESS) {
	    /* write partition attributes */
	    status = RegSetValueEx(vpKey, AFSREG_SVR_SVC_AFSTAB_DEVNAME_VALUE,
				   0, REG_SZ, vpDev, (DWORD)strlen(vpDev) + 1);

	    RegCloseKey(vpKey);
	}

	RegCloseKey(tabKey);
    }

    if (status) {
	errno = nterr_nt2unix(status, EIO);
	return -1;
    }
    return 0;
}
コード例 #4
0
ファイル: cfghost.c プロジェクト: maxendpoint/openafs_cvs
/*
 * cfg_HostPartitionNameValid() -- check partition name syntax.
 */
int ADMINAPI
cfg_HostPartitionNameValid(const char *partName,	/* partition name */
			   short *isValidP,	/* syntax is valid */
			   afs_status_p st)
{				/* completion status */
    int rc = 1;
    afs_status_t tst = 0;

    /* validate parameters */

    if (partName == NULL) {
	tst = ADMCFGPARTITIONNAMENULL;
    } else if (isValidP == NULL) {
	tst = ADMCFGVALIDFLAGPNULL;
    }

    /* check name syntax */

#ifdef AFS_NT40_ENV
    if (tst == 0) {
	*isValidP = vpt_PartitionNameValid(partName);
    }
#else
    /* function not yet implemented for Unix */
    if (tst == 0) {
	tst = ADMCFGNOTSUPPORTED;
    }
#endif

    if (tst != 0) {
	rc = 0;
    }
    if (st != NULL) {
	*st = tst;
    }
    return rc;
}
コード例 #5
0
ファイル: cfghost.c プロジェクト: maxendpoint/openafs_cvs
/*
 * cfg_HostPartitionTableAddEntry() -- Add or update AFS partition table entry.
 */
int ADMINAPI
cfg_HostPartitionTableAddEntry(void *hostHandle,	/* host config handle */
			       const char *partName,	/* partition name */
			       const char *devName,	/* device name */
			       afs_status_p st)
{				/* completion status */
    int rc = 1;
    afs_status_t tst2, tst = 0;
    cfg_host_p cfg_host = (cfg_host_p) hostHandle;

#ifdef AFS_NT40_ENV
    /* validate parameters */

    if (!cfgutil_HostHandleValidate(cfg_host, &tst2)) {
	tst = tst2;
    } else if (partName == NULL) {
	tst = ADMCFGPARTITIONNAMENULL;
    } else if (!vpt_PartitionNameValid(partName)) {
	tst = ADMCFGPARTITIONNAMEBAD;
    } else if (devName == NULL) {
	tst = ADMCFGDEVICENAMENULL;
    } else if (!vpt_DeviceNameValid(devName)) {
	tst = ADMCFGDEVICENAMEBAD;
    }

    /* remote configuration not yet supported in this function */

    if (tst == 0) {
	if (!cfg_host->is_local) {
	    tst = ADMCFGNOTSUPPORTED;
	}
    }

    /* add entry to table */

    if (tst == 0) {
	struct vptab vpentry;

	strcpy(vpentry.vp_name, partName);
	strcpy(vpentry.vp_dev, devName);

	if (vpt_AddEntry(&vpentry)) {
	    if (errno == EACCES) {
		tst = ADMNOPRIV;
	    } else if (errno == EINVAL) {
		/* shouldn't happen since checked partition/dev names */
		tst = ADMCFGVPTABLEENTRYBAD;
	    } else {
		tst = ADMCFGVPTABLEWRITEFAILED;
	    }
	}
    }
#else
    /* function not yet implemented for unix */
    if (tst == 0) {
	tst = ADMCFGNOTSUPPORTED;
    }
#endif /* AFS_NT40_ENV */

    if (tst != 0) {
	rc = 0;
    }
    if (st != NULL) {
	*st = tst;
    }
    return rc;
}