Exemplo n.º 1
0
static TUI_MENU_CALLBACK(radio_type_check_callback)
{
    int drive = (int)param >> 16;
    int type = (int)param & 0xffff;
    int value;
    int i;
    int support = (is_fs(type) || drive_check_type(type, drive - 8));

    if (!support) {
        return "N/A";
    }

    if (been_activated) {
        if (is_fs(type)) {
            resources_set_int_sprintf("IECDevice%i", 1, drive);
            resources_set_int_sprintf("FileSystemDevice%i", type, drive);
        } else {
            if (has_fs()) {
                resources_set_int_sprintf("IECDevice%i", 0, drive);
            }
            resources_set_int_sprintf("Drive%iType", type, drive);
        }
        *become_default = 1;
        ui_update_menus();
    } else {
        if (check_current_drive_type(type, drive)) {
            *become_default = 1;
        }
    }
}
Exemplo n.º 2
0
static int get_drive_type(int drive)
{
    int iecdevice = 0;
    int fsdevice;
    int drivetype;

    if (has_fs()) {
        resources_get_int_sprintf("IECDevice%i", &iecdevice, drive);
        resources_get_int_sprintf("FileSystemDevice%i", &fsdevice, drive);
    }
    resources_get_int_sprintf("Drive%iType", &drivetype, drive);
    if (iecdevice) {
        return fsdevice;
    } else {
        return drivetype;
    }
}
Exemplo n.º 3
0
static int check_current_drive_type(int type, int drive)
{
    int iecdevice = 0;
    int fsdevice;
    int drivetype;

    if (has_fs()) {
        resources_get_int_sprintf("IECDevice%i", &iecdevice, drive);
        resources_get_int_sprintf("FileSystemDevice%i", &fsdevice, drive);
    }
    resources_get_int_sprintf("Drive%iType", &drivetype, drive);
    if (iecdevice) {
        if (type == fsdevice) {
            return 1;
        }
    } else {
        if (type == drivetype) {
            return 1;
        }
    }
    return 0;
}
Exemplo n.º 4
0
/*
 * Use the heuristics to check for a filesystem on the slice.
 */
int
inuse_fs(char *slice, nvlist_t *attrs, int *errp)
{
	struct 	heuristic	*hp;
	time_t	curr_time;
	int	found = 0;


	*errp = 0;

	if (slice == NULL) {
	    return (0);
	}

	/*
	 * We get the list of heuristic programs one time.
	 */
	(void) mutex_lock(&init_lock);
	if (!initialized) {
	    *errp = load_heuristics();

	    if (*errp == 0) {
		initialized = 1;
	    }
	}
	(void) mutex_unlock(&init_lock);

	/* Run each of the heuristics. */
	for (hp = hlist; hp; hp = hp->next) {
	    if (has_fs(hp->prog, slice)) {
		libdiskmgt_add_str(attrs, DM_USED_BY, DM_USE_FS, errp);
		libdiskmgt_add_str(attrs, DM_USED_NAME, hp->type, errp);
		found = 1;
	    }
	}

	if (*errp != 0)
		return (found);

	/*
	 * Second heuristic used is the check for an entry in vfstab
	 */

	(void) mutex_lock(&vfstab_lock);
	curr_time = time(NULL);

	if (timestamp < curr_time && (curr_time - timestamp) > 60) {
		free_vfstab(vfstab_listp);
		*errp = load_vfstab();
		timestamp = curr_time;
	}

	if (*errp == 0) {
	    struct vfstab_list	*listp;
	    listp = vfstab_listp;

	    while (listp != NULL) {
		if (strcmp(slice, listp->special) == 0) {
		    char *mountp = "";

		    if (listp->mountp != NULL)
			mountp = listp->mountp;

		    libdiskmgt_add_str(attrs, DM_USED_BY, DM_USE_VFSTAB, errp);
		    libdiskmgt_add_str(attrs, DM_USED_NAME, mountp, errp);
		    found = 1;
		}
		listp = listp->next;
	    }
	}
	(void) mutex_unlock(&vfstab_lock);
	return (found);
}
Exemplo n.º 5
0
static int is_fs(int type)
{
    return ((type == 0 || type == ATTACH_DEVICE_FS || type == ATTACH_DEVICE_REAL || type == ATTACH_DEVICE_RAW) && has_fs());
}