Add vg-activate{,-all} commands, and resize recipe.

This commit is contained in:
Richard Jones
2009-05-18 17:16:24 +01:00
parent adf0974245
commit 85ed8cef99
29 changed files with 867 additions and 24 deletions

View File

@@ -2864,4 +2864,54 @@ public class GuestFS {
private native String _sfdisk_disk_geometry (long g, String device)
throws LibGuestFSException;
/**
* activate or deactivate all volume groups
*
* This command activates or (if "activate" is false)
* deactivates all logical volumes in all volume groups. If
* activated, then they are made known to the kernel, ie.
* they appear as "/dev/mapper" devices. If deactivated,
* then those devices disappear.
*
* This command is the same as running "vgchange -a y|n"
*
* @throws LibGuestFSException
*/
public void vg_activate_all (boolean activate)
throws LibGuestFSException
{
if (g == 0)
throw new LibGuestFSException ("vg_activate_all: handle is closed");
_vg_activate_all (g, activate);
}
private native void _vg_activate_all (long g, boolean activate)
throws LibGuestFSException;
/**
* activate or deactivate some volume groups
*
* This command activates or (if "activate" is false)
* deactivates all logical volumes in the listed volume
* groups "volgroups". If activated, then they are made
* known to the kernel, ie. they appear as "/dev/mapper"
* devices. If deactivated, then those devices disappear.
*
* This command is the same as running "vgchange -a y|n
* volgroups..."
*
* Note that if "volgroups" is an empty list then all
* volume groups are activated or deactivated.
*
* @throws LibGuestFSException
*/
public void vg_activate (boolean activate, String[] volgroups)
throws LibGuestFSException
{
if (g == 0)
throw new LibGuestFSException ("vg_activate: handle is closed");
_vg_activate (g, activate, volgroups);
}
private native void _vg_activate (long g, boolean activate, String[] volgroups)
throws LibGuestFSException;
}

View File

@@ -2847,3 +2847,50 @@ Java_com_redhat_et_libguestfs_GuestFS__1sfdisk_1disk_1geometry
return jr;
}
JNIEXPORT void JNICALL
Java_com_redhat_et_libguestfs_GuestFS__1vg_1activate_1all
(JNIEnv *env, jobject obj, jlong jg, jboolean jactivate)
{
guestfs_h *g = (guestfs_h *) (long) jg;
int r;
int activate;
activate = jactivate;
r = guestfs_vg_activate_all (g, activate);
if (r == -1) {
throw_exception (env, guestfs_last_error (g));
return ;
}
}
JNIEXPORT void JNICALL
Java_com_redhat_et_libguestfs_GuestFS__1vg_1activate
(JNIEnv *env, jobject obj, jlong jg, jboolean jactivate, jobjectArray jvolgroups)
{
guestfs_h *g = (guestfs_h *) (long) jg;
int r;
int activate;
int volgroups_len;
const char **volgroups;
int i;
activate = jactivate;
volgroups_len = (*env)->GetArrayLength (env, jvolgroups);
volgroups = guestfs_safe_malloc (g, sizeof (char *) * (volgroups_len+1));
for (i = 0; i < volgroups_len; ++i) {
jobject o = (*env)->GetObjectArrayElement (env, jvolgroups, i);
volgroups[i] = (*env)->GetStringUTFChars (env, o, NULL);
}
volgroups[volgroups_len] = NULL;
r = guestfs_vg_activate (g, activate, volgroups);
for (i = 0; i < volgroups_len; ++i) {
jobject o = (*env)->GetObjectArrayElement (env, jvolgroups, i);
(*env)->ReleaseStringUTFChars (env, o, volgroups[i]);
}
free (volgroups);
if (r == -1) {
throw_exception (env, guestfs_last_error (g));
return ;
}
}