diff options
author | David Zeuthen <davidz@redhat.com> | 2010-10-08 21:14:04 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2010-10-08 21:14:04 -0400 |
commit | c7d3f3c90a522d35a7385186fe4f2f6ddad6c8ed (patch) | |
tree | 2aba6c90b2b77f9869ad181de6a774032689e8f8 | |
parent | 86300b6389dffdfca9909de8a1ceec0d428211c3 (diff) |
Use item-prefixed options for specifying what device to act on
This makes the configuration files slighty more readable and also
cleans up the API somewhat.
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | doc/stc-sections.txt | 1 | ||||
-rw-r--r-- | doc/stc.conf.xml | 169 | ||||
-rw-r--r-- | stc/stc.c | 9 | ||||
-rw-r--r-- | stc/stcitem.c | 58 | ||||
-rw-r--r-- | stc/stcitem.h | 1 | ||||
-rw-r--r-- | stc/stcmonitor.c | 59 | ||||
-rw-r--r-- | stc/stcprivate.h | 1 | ||||
-rw-r--r-- | stc/test.c | 44 | ||||
-rw-r--r-- | stc/testdata/semi_valid_conf/stc.conf | 21 | ||||
-rw-r--r-- | stc/testdata/semi_valid_conf/stc.conf.d/10.conf | 2 | ||||
-rw-r--r-- | stc/testdata/semi_valid_conf/stc.conf.d/50.conf | 2 | ||||
-rw-r--r-- | stc/testdata/semi_valid_conf/stc.conf.d/50.conf.wrong-extension | 2 | ||||
-rw-r--r-- | stc/testdata/semi_valid_conf/stc.conf.d/90.conf | 4 | ||||
-rw-r--r-- | stc/testdata/semi_valid_conf/stc.conf.d/91.conf | 2 |
14 files changed, 192 insertions, 183 deletions
diff --git a/doc/stc-sections.txt b/doc/stc-sections.txt index 057c036..db7c608 100644 --- a/doc/stc-sections.txt +++ b/doc/stc-sections.txt @@ -25,7 +25,6 @@ StcItemState stc_item_get_id stc_item_get_item_type stc_item_get_comment -stc_item_get_target stc_item_get_option stc_item_get_option_keys stc_item_get_dependencies diff --git a/doc/stc.conf.xml b/doc/stc.conf.xml index a32fc1f..6dfbb78 100644 --- a/doc/stc.conf.xml +++ b/doc/stc.conf.xml @@ -91,7 +91,7 @@ MyData_LV_PV1 MyData_LV_PV2 MyData_LV_PV3 </para> <programlisting> [Filesystem MyDisk] -Device=/dev/disk/by-uuid/1234:5678 +FilesystemDevice=/dev/disk/by-uuid/1234:5678 FilesystemMountPath=/mnt/somewhere </programlisting> <para> @@ -117,17 +117,6 @@ FilesystemMountPath=/mnt/somewhere <variablelist> <varlistentry> - <term><literal>Device, Label, UUID, Name</literal></term> - <listitem> - <para> - Exactly one of these keys can be used to refer to the device - in question. See each item type for what subset of these - keys can be used. - </para> - </listitem> - </varlistentry> - - <varlistentry> <term><literal>Comment</literal></term> <listitem> <para> @@ -178,15 +167,64 @@ FilesystemMountPath=/mnt/somewhere <title>Filesystem Items</title> <para> Items of type <literal>Filesystem</literal> are used to mount - block devices into the filesystem tree — you can use keys - <literal>Device</literal>, <literal>UUID</literal> and - <literal>Label</literal> to refer to the device. The option - <literal>FilesystemMountPath</literal> is mandatory and is used to - specify the path where the device should be mounted. The option - <literal>FilesystemOptions</literal> is optional and is a - comma-separated list of options to pass to the - <citerefentry><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> - command. + block devices into the filesystem tree. The follow options are + supported: + </para> + + <variablelist> + <varlistentry> + <term><literal>FilesystemDevice</literal></term> + <listitem> + <para> + The block device to mount. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>FilesystemLabel</literal></term> + <listitem> + <para> + The label of the filesystem to mount. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>FilesystemUUID</literal></term> + <listitem> + <para> + The UUID of the filesystem to mount. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>FilesystemMountPath</literal></term> + <listitem> + <para> + The filesystem path where the filesystem is mounted. This option is mandatory. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>FilesystemOptions</literal></term> + <listitem> + <para> + A comma-separated list of options to pass to the + <citerefentry><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> + command. This option is optional. + </para> + </listitem> + </varlistentry> + </variablelist> + + <para> + Exactly one of the <literal>FilesystemDevice</literal>, + <literal>FilesystemUUID</literal> or + <literal>FilesystemLabel</literal> options must be set to specify + what filesystem to mount. </para> <refsect2> @@ -195,25 +233,25 @@ FilesystemMountPath=/mnt/somewhere # Mount by label # [Filesystem id1] -Label=Some Label +FilesystemLabel=Some Label FilesystemMountPath=/mnt/id1 # Mount by UUID # [Filesystem id2] -UUID=4e057fd9-bae5-4a12-83b5-2f654d42edb1 +FilesystemUUID=4e057fd9-bae5-4a12-83b5-2f654d42edb1 FilesystemMountPath=/mnt/id2 # Mount by device (in this case, a persistent device name) # [Filesystem id3] -Device=/dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part1 +FilesystemDevice=/dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part1 FilesystemMountPath=/mnt/id3 # Specify filesystem options # [Filesystem id4] -Label=EOS_DIGITAL +FilesystemLabel=EOS_DIGITAL FilesystemMountPath=/media/My Photos FilesystemOptions=umask=0022,noatime </programlisting> @@ -224,14 +262,38 @@ FilesystemOptions=umask=0022,noatime <title>Luks Items</title> <para> Items of type <literal>Luks</literal> are used to unlock an - encrypted device. The key <literal>UUID</literal> can be used to - refer to the device. The option <literal>LuksPassphrase</literal> - is <emphasis>optional</emphasis> and if set, contains the - passphrase used to unlock the device. If the - <literal>LuksPassphrase</literal> option is not set, then the user - is asked for the passphrase when starting the device. + encrypted device. The following options are supported: </para> + <variablelist> + <varlistentry> + <term><literal>LuksUUID</literal></term> + <listitem> + <para> + The UUID of the cryptotext device. This option is mandatory. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>LuksMappingName</literal></term> + <listitem> + <para> + The name to use for the unlocked <literal>dm-crypt</literal> device. This option is optional. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>LuksPassphrase</literal></term> + <listitem> + <para> + The passphrase used to unlock the device. This option is optional. + </para> + </listitem> + </varlistentry> + </variablelist> + <note> <title>Security Note</title> <para> @@ -244,19 +306,13 @@ FilesystemOptions=umask=0022,noatime </para> </note> - <para> - The option <literal>LuksMappingName</literal> is likewise optional - and if set, then the given name will be used for the resulting - <literal>dm-crypt</literal> device. - </para> - <refsect2> <title>Examples</title> <programlisting> # Passphrase and mapping name given # [Luks sekrit_Luks] -UUID=5b2aeadf-7f10-4df9-92f2-0bc13123d6e5 +LuksUUID=5b2aeadf-7f10-4df9-92f2-0bc13123d6e5 LuksPassphrase=xyz123 LuksMappingName=sekrit @@ -267,7 +323,7 @@ LuksMappingName=sekrit # tandem when running stc(8). # [Filesystem sekrit] -UUID=9639-06F4 +FilesystemUUID=9639-06F4 FilesystemMountPath=/mnt/sekrit Depends=sekrit_Luks </programlisting> @@ -279,9 +335,34 @@ Depends=sekrit_Luks <para> Items of type <literal>Raid</literal> are used to assemble <citerefentry><refentrytitle>md</refentrytitle><manvolnum>4</manvolnum></citerefentry> - aka Linux Software Raid devices. The keys <literal>UUID</literal> - and <literal>Name</literal> can be used to refer to the RAID - array. + aka Linux Software Raid devices. The following options are + supported: + </para> + + <variablelist> + <varlistentry> + <term><literal>RaidUUID</literal></term> + <listitem> + <para> + The UUID of the RAID array. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><literal>RaidName</literal></term> + <listitem> + <para> + The name of the RAID array. + </para> + </listitem> + </varlistentry> + </variablelist> + + <para> + Exactly one of the <literal>RaidUUID</literal> or + <literal>RaidName</literal> options must be set to specify what + RAID array to assemble. </para> <refsect2> @@ -290,12 +371,12 @@ Depends=sekrit_Luks # Refer to array by UUID # [Raid BigStorage] -UUID=a4a5646e:933c7856:23bfc059:6e17b7ec +RaidUUID=a4a5646e:933c7856:23bfc059:6e17b7ec # Refer to array by name (typically in the homehost:name format) # [Raid MyRaid] -Name=x61:MyRaid +RaidName=x61:MyRaid </programlisting> </refsect2> </refsect1> @@ -284,7 +284,6 @@ handle_command_list (gint *argc, StcItemType type; const gchar *id; const gchar *comment; - const gchar *target; const gchar *const *options; const gchar *const *deps; const gchar *const *slave_devices; @@ -294,7 +293,6 @@ handle_command_list (gint *argc, type = stc_item_get_item_type (item); id = stc_item_get_id (item); comment = stc_item_get_comment (item); - target = stc_item_get_target (item); g_print ("%s%s%s:%s\n", _color_get (_COLOR_FG_BLUE), @@ -309,13 +307,6 @@ handle_command_list (gint *argc, enum_to_str (STC_TYPE_ITEM_TYPE, type), _color_get (_COLOR_RESET)); - g_print (" %sTarget:%s %s%s%s\n", - _color_get (_COLOR_FG_WHITE), - _color_get (_COLOR_RESET), - _color_get (_COLOR_FG_GREEN), - target, - _color_get (_COLOR_RESET)); - if (comment != NULL) { g_print (" %sComment:%s %s%s%s\n", diff --git a/stc/stcitem.c b/stc/stcitem.c index 6c7a154..0c35db6 100644 --- a/stc/stcitem.c +++ b/stc/stcitem.c @@ -60,7 +60,6 @@ struct _StcItem StcItemType type; gchar *id; gchar *comment; - gchar *target; GHashTable *options; gchar **depends; gboolean auto_val; @@ -108,7 +107,6 @@ stc_item_finalize (GObject *object) g_free (item->id); g_free (item->comment); - g_free (item->target); g_hash_table_unref (item->options); g_strfreev (item->depends); @@ -184,13 +182,6 @@ stc_item_get_comment (StcItem *item) return item->comment; } -const gchar * -stc_item_get_target (StcItem *item) -{ - g_return_val_if_fail (STC_IS_ITEM (item), NULL); - return item->target; -} - StcItemState stc_item_get_state (StcItem *item) { @@ -202,7 +193,6 @@ StcItem * _stc_item_new (StcMonitor *monitor, StcItemType type, const gchar *id, - const gchar *target, const gchar *comment, GHashTable *options, const gchar *const *depends, @@ -218,7 +208,6 @@ _stc_item_new (StcMonitor *monitor, item->monitor = monitor; g_object_add_weak_pointer (G_OBJECT (item->monitor), (gpointer*) &item->monitor); item->id = g_strdup (id); - item->target = g_strdup (target); item->comment = g_strdup (comment); item->type = type; item->options = g_hash_table_ref (options); @@ -301,13 +290,6 @@ _stc_item_update (StcItem *item, StcItem *other) g_assert_cmpstr (item->id, ==, other->id); - if (g_strcmp0 (item->target, other->target) != 0) - { - g_free (item->target); - item->target = g_strdup (other->target); - changed = TRUE; - } - if (g_strcmp0 (item->comment, other->comment) != 0) { g_free (item->comment); @@ -380,6 +362,7 @@ _stc_item_filesystem_get_device (StcItem *item, GList *devices; GList *l; gchar **mount_paths; + const gchar *value; g_return_val_if_fail (STC_IS_ITEM (item), NULL); g_return_val_if_fail (item->type == STC_ITEM_TYPE_FILESYSTEM, NULL); @@ -387,10 +370,9 @@ _stc_item_filesystem_get_device (StcItem *item, ret = NULL; mount_paths = NULL; - if (g_str_has_prefix (item->target, "Device=")) + if ((value = g_hash_table_lookup (item->options, "FilesystemDevice")) != NULL) { - device = g_udev_client_query_by_device_file (_stc_monitor_get_gudev_client (item->monitor), - item->target + sizeof "Device=" - 1); + device = g_udev_client_query_by_device_file (_stc_monitor_get_gudev_client (item->monitor), value); if (device != NULL) { if (g_strcmp0 (g_udev_device_get_property (device, "ID_FS_USAGE"), "filesystem") == 0) @@ -398,12 +380,12 @@ _stc_item_filesystem_get_device (StcItem *item, g_object_unref (device); } } - else if (g_str_has_prefix (item->target, "UUID=")) + else if ((value = g_hash_table_lookup (item->options, "FilesystemUUID")) != NULL) { devices = _g_udev_client_query_by_property (_stc_monitor_get_gudev_client (item->monitor), "block", "ID_FS_UUID", - item->target + sizeof "UUID=" - 1); + value); for (l = devices; l != NULL; l = l->next) { device = G_UDEV_DEVICE (l->data); @@ -416,12 +398,12 @@ _stc_item_filesystem_get_device (StcItem *item, g_list_foreach (devices, (GFunc) g_object_unref, NULL); g_list_free (devices); } - else if (g_str_has_prefix (item->target, "Label=")) + else if ((value = g_hash_table_lookup (item->options, "FilesystemLabel")) != NULL) { devices = _g_udev_client_query_by_property (_stc_monitor_get_gudev_client (item->monitor), "block", "ID_FS_LABEL", - item->target + sizeof "Label=" - 1); + value); for (l = devices; l != NULL; l = l->next) { device = G_UDEV_DEVICE (l->data); @@ -436,7 +418,7 @@ _stc_item_filesystem_get_device (StcItem *item, } else { - g_warning ("Unsupported target type %s for Filesystem", item->target); + g_warning ("Unsupported target for Filesystem"); } if (ret != NULL) @@ -485,6 +467,7 @@ _stc_item_mdraid_get_devices (StcItem *item, GList *devices; GList *l; GUdevDevice *device; + const gchar *value; md_devices = 0; md_level = NULL; @@ -492,13 +475,13 @@ _stc_item_mdraid_get_devices (StcItem *item, ret = NULL; /* see data/79-stc.rules for why STC_ORIG_MD_NAME, STC_ORIG_MD_UUID is used */ - if (g_str_has_prefix (item->target, "Name=")) + if ((value = g_hash_table_lookup (item->options, "RaidName")) != NULL) { /* first find the components */ devices = _g_udev_client_query_by_property (_stc_monitor_get_gudev_client (item->monitor), "block", "MD_NAME", - item->target + sizeof "Name=" - 1); + value); for (l = devices; l != NULL; l = l->next) { device = G_UDEV_DEVICE (l->data); @@ -520,7 +503,7 @@ _stc_item_mdraid_get_devices (StcItem *item, devices = _g_udev_client_query_by_property (_stc_monitor_get_gudev_client (item->monitor), "block", "STC_ORIG_MD_NAME", - item->target + sizeof "Name=" - 1); + value); for (l = devices; l != NULL; l = l->next) { device = G_UDEV_DEVICE (l->data); @@ -533,13 +516,13 @@ _stc_item_mdraid_get_devices (StcItem *item, g_list_foreach (devices, (GFunc) g_object_unref, NULL); g_list_free (devices); } - else if (g_str_has_prefix (item->target, "UUID=")) + else if ((value = g_hash_table_lookup (item->options, "RaidUUID")) != NULL) { /* first find the components */ devices = _g_udev_client_query_by_property (_stc_monitor_get_gudev_client (item->monitor), "block", "MD_UUID", - item->target + sizeof "UUID=" - 1); + value); for (l = devices; l != NULL; l = l->next) { device = G_UDEV_DEVICE (l->data); @@ -561,7 +544,7 @@ _stc_item_mdraid_get_devices (StcItem *item, devices = _g_udev_client_query_by_property (_stc_monitor_get_gudev_client (item->monitor), "block", "STC_ORIG_MD_UUID", - item->target + sizeof "UUID=" - 1); + value); for (l = devices; l != NULL; l = l->next) { device = G_UDEV_DEVICE (l->data); @@ -576,7 +559,7 @@ _stc_item_mdraid_get_devices (StcItem *item, } else { - g_warning ("Unsupported target type %s for Luks", item->target); + g_warning ("Unsupported target for Raid"); } ret_component_devices = g_list_reverse (ret_component_devices); @@ -734,18 +717,19 @@ _stc_item_luks_get_devices (StcItem *item, GList *l; gchar *luks_uuid; gchar *uuid_prefix; + const gchar *value; device_with_crypto = NULL; unlocked_device = NULL; luks_uuid = NULL; - if (g_str_has_prefix (item->target, "UUID=")) + if ((value = g_hash_table_lookup (item->options, "LuksUUID")) != NULL) { - luks_uuid = _strdup_without_dashes (item->target + sizeof "UUID=" - 1); + luks_uuid = _strdup_without_dashes (value); devices = _g_udev_client_query_by_property (_stc_monitor_get_gudev_client (item->monitor), "block", "ID_FS_UUID", - item->target + sizeof "UUID=" - 1); + value); for (l = devices; l != NULL; l = l->next) { device = G_UDEV_DEVICE (l->data); @@ -761,7 +745,7 @@ _stc_item_luks_get_devices (StcItem *item, } else { - g_warning ("Unsupported target type %s for Luks", item->target); + g_warning ("Unsupported target for Luks"); } /* if a LUKS device is unlocked, then DM_UUID is set to uuid_prefix plus the name - so diff --git a/stc/stcitem.h b/stc/stcitem.h index a5f6b8f..406f372 100644 --- a/stc/stcitem.h +++ b/stc/stcitem.h @@ -40,7 +40,6 @@ GType stc_item_get_type (void) G_GNUC_CONST; StcItemType stc_item_get_item_type (StcItem *item); const gchar *stc_item_get_id (StcItem *item); const gchar *stc_item_get_comment (StcItem *item); -const gchar *stc_item_get_target (StcItem *item); const gchar* const *stc_item_get_option_keys (StcItem *item); const gchar *stc_item_get_option (StcItem *item, const gchar *key); diff --git a/stc/stcmonitor.c b/stc/stcmonitor.c index 480f3f2..4877957 100644 --- a/stc/stcmonitor.c +++ b/stc/stcmonitor.c @@ -584,7 +584,6 @@ static gboolean check_validity (StcMonitor *monitor, const gchar *item_id, StcItemType item_type, - const gchar *target, GHashTable *options, const gchar *path, gint line_no) @@ -596,15 +595,15 @@ check_validity (StcMonitor *monitor, switch (item_type) { case STC_ITEM_TYPE_FILESYSTEM: - if (!(g_str_has_prefix (target, "Device=") || - g_str_has_prefix (target, "UUID=") || - g_str_has_prefix (target, "Label="))) + if (!(g_hash_table_lookup (options, "FilesystemDevice") != NULL || + g_hash_table_lookup (options, "FilesystemUUID") != NULL || + g_hash_table_lookup (options, "FilesystemLabel") != NULL)) { stc_monitor_emit_stc_error (monitor, path, line_no, STC_ERROR_FAILED, - "Filesystem item %s has unsupported target type (Device, UUID and Label is supported).", + "Filesystem item %s needs one of FilesystemDevice, FilesystemUUID and FilesystemLabel options set.", item_id); goto out; } @@ -621,27 +620,27 @@ check_validity (StcMonitor *monitor, break; case STC_ITEM_TYPE_RAID: - if (!(g_str_has_prefix (target, "UUID=") || - g_str_has_prefix (target, "Name="))) + if (!(g_hash_table_lookup (options, "RaidUUID") != NULL || + g_hash_table_lookup (options, "RaidName") != NULL)) { stc_monitor_emit_stc_error (monitor, path, line_no, STC_ERROR_FAILED, - "Raid item %s has unsupported target type (UUID and Name is supported).", + "Raid item %s needs one of RaidUUID and RaidName options set.", item_id); goto out; } break; case STC_ITEM_TYPE_LUKS: - if (!(g_str_has_prefix (target, "UUID="))) + if (!(g_hash_table_lookup (options, "LuksUUID") != NULL)) { stc_monitor_emit_stc_error (monitor, path, line_no, STC_ERROR_FAILED, - "Raid item %s has unsupported target type (UUID is supported).", + "Luks item %s needs the LuksUUID option set.", item_id); goto out; } @@ -689,10 +688,8 @@ stc_monitor_load_one_file (StcMonitor *monitor, gchar **tokens; StcItemType item_type; const gchar *item_id; - gchar *target; gchar *comment; gchar *sort_key; - gchar *s; StcItem *item; GHashTable *options; gchar **depends_strv; @@ -702,7 +699,6 @@ stc_monitor_load_one_file (StcMonitor *monitor, gboolean auto_val; tokens = NULL; - target = NULL; comment = NULL; sort_key = NULL; options = NULL; @@ -748,40 +744,6 @@ stc_monitor_load_one_file (StcMonitor *monitor, goto process_next_item; } - /* resolve target (TODO: maybe bail if more than one of the allowed keys are present) */ - if ((s = g_key_file_get_string (key_file, group, "Device", NULL)) != NULL) - { - target = g_strdup_printf ("Device=%s", s); - g_free (s); - } - else if ((s = g_key_file_get_string (key_file, group, "UUID", NULL)) != NULL) - { - target = g_strdup_printf ("UUID=%s", s); - g_free (s); - } - else if ((s = g_key_file_get_string (key_file, group, "Label", NULL)) != NULL) - { - target = g_strdup_printf ("Label=%s", s); - g_free (s); - } - else if ((s = g_key_file_get_string (key_file, group, "Name", NULL)) != NULL) - { - target = g_strdup_printf ("Name=%s", s); - g_free (s); - } - else - { - stc_monitor_emit_stc_error (monitor, - path, - -1, - STC_ERROR_PARSE_ERROR, - "No target key (supported: Device, UUID, Label, Name) keys found " - "in item %s of type %s.", - item_id, - tokens[0]); - goto process_next_item; - } - /* Handle item specific options */ options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); keys = g_key_file_get_keys (key_file, group, NULL, NULL); @@ -832,7 +794,6 @@ stc_monitor_load_one_file (StcMonitor *monitor, if (!check_validity (monitor, item_id, item_type, - target, options, path, -1)) @@ -845,7 +806,6 @@ stc_monitor_load_one_file (StcMonitor *monitor, item = _stc_item_new (monitor, item_type, item_id, - target, comment, options, (const gchar *const *) depends_strv, @@ -857,7 +817,6 @@ stc_monitor_load_one_file (StcMonitor *monitor, process_next_item: g_strfreev (tokens); - g_free (target); g_free (comment); g_free (sort_key); g_strfreev (depends_strv); diff --git a/stc/stcprivate.h b/stc/stcprivate.h index 399512d..d61d16e 100644 --- a/stc/stcprivate.h +++ b/stc/stcprivate.h @@ -46,7 +46,6 @@ _StcMount * __stc_mount_new (dev_t dev, StcItem *_stc_item_new (StcMonitor *monitor, StcItemType type, const gchar *id, - const gchar *target, const gchar *nick_name, GHashTable *options, const gchar *const *depends, @@ -67,12 +67,10 @@ static void item_append_str (StcItem *item, g_string_append_printf (str, "id `%s'\n" - "target `%s'\n" "comment `%s'\n" "type %s\n" "options ", stc_item_get_id (item) != NULL ? stc_item_get_id (item) : "(none)", - stc_item_get_target (item) != NULL ? stc_item_get_target (item) : "(none)", stc_item_get_comment (item) != NULL ? stc_item_get_comment (item) : "(none)", item_type_to_str (stc_item_get_item_type (item))); @@ -190,7 +188,7 @@ test_stc_semi_valid_conf (void) SRCDIR "/testdata/semi_valid_conf/stc.conf: Error parsing item type `XYZType' in group `XYZType ValidIdentifier' (stc-error-quark, 1)\n" SRCDIR "/testdata/semi_valid_conf/stc.conf: Invalid item identifer `with-dash' in group `Filesystem with-dash'. Only characters in [a-zA-Z0-9_] are supported. (stc-error-quark, 1)\n" SRCDIR "/testdata/semi_valid_conf/stc.conf: Error parsing group name `Filesystem with space' (stc-error-quark, 1)\n" - SRCDIR "/testdata/semi_valid_conf/stc.conf: Raid item bar has unsupported target type (UUID and Name is supported). (stc-error-quark, 0)\n" + SRCDIR "/testdata/semi_valid_conf/stc.conf: Raid item bar needs one of RaidUUID and RaidName options set. (stc-error-quark, 0)\n" SRCDIR "/testdata/semi_valid_conf/stc.conf.d/91.conf: Encountered item with duplicate id `multiple_instances_same_id'. Ignoring previous items. (stc-error-quark, 2)\n" SRCDIR "/testdata/semi_valid_conf/stc.conf: Item ItemWithUnresolved has unresolved dependency NonExisting. (stc-error-quark, 3)\n" ); @@ -206,83 +204,81 @@ test_stc_semi_valid_conf (void) g_list_free (items); g_assert_cmpstr (str2->str, ==, "id `in_pri_10'\n" - "target `Device=/dev/sda'\n" "comment `(none)'\n" "type filesystem\n" "options FilesystemMountPath -> `/mnt/10'\n" + " FilesystemDevice -> `/dev/sda'\n" "dependencies (none)\n" "auto 0\n" "\n" "id `in_pri_50'\n" - "target `Device=/dev/sda'\n" "comment `(none)'\n" "type filesystem\n" "options FilesystemMountPath -> `/mnt/50'\n" + " FilesystemDevice -> `/dev/sda'\n" "dependencies (none)\n" "auto 0\n" "\n" "id `in_pri_90'\n" - "target `Device=/dev/sda'\n" "comment `(none)'\n" "type filesystem\n" "options FilesystemMountPath -> `/mnt/90'\n" + " FilesystemDevice -> `/dev/sda'\n" "dependencies (none)\n" "auto 0\n" "\n" "id `multiple_instances_same_id'\n" - "target `Device=/dev/multiple_instances_same_id/second'\n" "comment `(none)'\n" "type filesystem\n" "options FilesystemMountPath -> `/mnt/m_second'\n" + " FilesystemDevice -> `/dev/multiple_instances_same_id/second'\n" "dependencies (none)\n" "auto 0\n" "\n" "id `BigStorage'\n" - "target `Device=/dev/disk/md-uuid-01234:56789'\n" "comment `BigStorage'\n" "type filesystem\n" "options FilesystemMountPath -> `/mnt/BigStorage'\n" + " FilesystemDevice -> `/dev/disk/md-uuid-01234:56789'\n" "dependencies BigStorage_mdraid\n" "auto 0\n" "\n" "id `BigStorage_mdraid'\n" - "target `UUID=01234:56789'\n" "comment `BigStorage RAID Array'\n" "type raid\n" - "options (none)\n" + "options RaidUUID -> `01234:56789'\n" "dependencies (none)\n" "auto 0\n" "\n" "id `SekritStuff'\n" - "target `Device=/dev/disk/by-uuid/1234'\n" "comment `My Secret Stuff'\n" "type filesystem\n" "options FilesystemMountPath -> `/mnt/SekritStuff'\n" + " FilesystemDevice -> `/dev/disk/by-uuid/1234'\n" " FilesystemOptions -> `noatime,dirsync'\n" "dependencies SekritStuff_Luks\n" "auto 1\n" "\n" "id `SekritStuff_Luks'\n" - "target `UUID=12345'\n" "comment `My Secret Stuff (Encrypted)'\n" "type luks\n" - "options LuksPassphrase -> `xyz123'\n" + "options LuksUUID -> `12345'\n" + " LuksPassphrase -> `xyz123'\n" "dependencies (none)\n" "auto 0\n" "\n" "id `ItemWithUnresolved'\n" - "target `Device=/dev/sda'\n" "comment `(none)'\n" "type filesystem\n" "options FilesystemMountPath -> `/mnt/Z'\n" + " FilesystemDevice -> `/dev/sda'\n" "dependencies NonExisting\n" "auto 0\n" "\n" "id `OtherRaid'\n" - "target `Name=homehost:array_name'\n" "comment `Other RAID'\n" "type raid\n" - "options (none)\n" + "options RaidName -> `homehost:array_name'\n" "dependencies (none)\n" "auto 1\n" "\n" @@ -337,7 +333,7 @@ check_state (StcMonitor *monitor, case 1: g_assert_cmpstr (stc_item_get_id (item), ==, "item2"); g_assert_cmpint (event, ==, _EVENT_ADDED); - g_assert_cmpstr (stc_item_get_target (item), ==, "Device=/dev/sdc"); + g_assert_cmpstr (stc_item_get_option (item, "FilesystemDevice"), ==, "/dev/sdc"); break; case 2: @@ -348,7 +344,7 @@ check_state (StcMonitor *monitor, case 3: g_assert_cmpstr (stc_item_get_id (item), ==, "item2"); g_assert_cmpint (event, ==, _EVENT_CHANGED); - g_assert_cmpstr (stc_item_get_target (item), ==, "Device=/dev/sda"); + g_assert_cmpstr (stc_item_get_option (item, "FilesystemDevice"), ==, "/dev/sda"); break; case 4: @@ -444,7 +440,7 @@ test_stc_monitoring (void) error = NULL; rc = g_file_set_contents (filename, "[Filesystem item1]\n" - "Device=/dev/sdb\n" + "FilesystemDevice=/dev/sdb\n" "FilesystemMountPath=/item1", -1, &error); @@ -459,11 +455,11 @@ test_stc_monitoring (void) error = NULL; rc = g_file_set_contents (filename, "[Filesystem item1]\n" - "Device=/dev/sdb\n" + "FilesystemDevice=/dev/sdb\n" "FilesystemMountPath=/item1" "\n" "[Filesystem item2]\n" - "Device=/dev/sdc\n" + "FilesystemDevice=/dev/sdc\n" "FilesystemMountPath=/item2", -1, &error); @@ -478,7 +474,7 @@ test_stc_monitoring (void) error = NULL; rc = g_file_set_contents (filename, "[Filesystem item2]\n" - "Device=/dev/sdc\n" + "FilesystemDevice=/dev/sdc\n" "FilesystemMountPath=/item2", -1, &error); @@ -493,7 +489,7 @@ test_stc_monitoring (void) error = NULL; rc = g_file_set_contents (filename, "[Filesystem item2]\n" - "Device=/dev/sda\n" + "FilesystemDevice=/dev/sda\n" "FilesystemMountPath=/item2", -1, &error); @@ -508,7 +504,7 @@ test_stc_monitoring (void) error = NULL; rc = g_file_set_contents (filename, "[Filesystem item3]\n" - "Device=/dev/sda\n" + "FilesystemDevice=/dev/sda\n" "FilesystemMountPath=/item3", -1, &error); diff --git a/stc/testdata/semi_valid_conf/stc.conf b/stc/testdata/semi_valid_conf/stc.conf index a9a38fe..bb31c2e 100644 --- a/stc/testdata/semi_valid_conf/stc.conf +++ b/stc/testdata/semi_valid_conf/stc.conf @@ -3,37 +3,38 @@ [Filesystem BigStorage] Comment=BigStorage -Device=/dev/disk/md-uuid-01234:56789 -FilesystemMountPath=/mnt/BigStorage Depends=BigStorage_mdraid -# this should cause a warning (item is not rejected) +# this should cause a warning because 'yes' is not accepted (item, however, is not rejected) Auto=yes +FilesystemDevice=/dev/disk/md-uuid-01234:56789 +FilesystemMountPath=/mnt/BigStorage [Raid BigStorage_mdraid] Comment=BigStorage RAID Array -UUID=01234:56789 +RaidUUID=01234:56789 [Filesystem SekritStuff] Comment=My Secret Stuff -Device=/dev/disk/by-uuid/1234 -FilesystemMountPath=/mnt/SekritStuff -FilesystemOptions=noatime,dirsync Depends=SekritStuff_Luks Auto=true +FilesystemDevice=/dev/disk/by-uuid/1234 +FilesystemMountPath=/mnt/SekritStuff +FilesystemOptions=noatime,dirsync [Luks SekritStuff_Luks] Comment=My Secret Stuff (Encrypted) -UUID=12345 +LuksUUID=12345 LuksPassphrase=xyz123 [Filesystem ItemWithUnresolved] -Device=/dev/sda +FilesystemDevice=/dev/sda FilesystemMountPath=/mnt/Z Depends=NonExisting [Raid OtherRaid] Comment=Other RAID -Name=homehost:array_name +RaidName=homehost:array_name +# Auto=1 is equivalent to Auto=true Auto=1 # ...and that we reject invalid items diff --git a/stc/testdata/semi_valid_conf/stc.conf.d/10.conf b/stc/testdata/semi_valid_conf/stc.conf.d/10.conf index d88d791..2dac405 100644 --- a/stc/testdata/semi_valid_conf/stc.conf.d/10.conf +++ b/stc/testdata/semi_valid_conf/stc.conf.d/10.conf @@ -1,4 +1,4 @@ [Filesystem in_pri_10] -Device=/dev/sda +FilesystemDevice=/dev/sda FilesystemMountPath=/mnt/10 diff --git a/stc/testdata/semi_valid_conf/stc.conf.d/50.conf b/stc/testdata/semi_valid_conf/stc.conf.d/50.conf index b2ac281..680f65e 100644 --- a/stc/testdata/semi_valid_conf/stc.conf.d/50.conf +++ b/stc/testdata/semi_valid_conf/stc.conf.d/50.conf @@ -1,4 +1,4 @@ [Filesystem in_pri_50] -Device=/dev/sda +FilesystemDevice=/dev/sda FilesystemMountPath=/mnt/50 diff --git a/stc/testdata/semi_valid_conf/stc.conf.d/50.conf.wrong-extension b/stc/testdata/semi_valid_conf/stc.conf.d/50.conf.wrong-extension index dc58712..8363364 100644 --- a/stc/testdata/semi_valid_conf/stc.conf.d/50.conf.wrong-extension +++ b/stc/testdata/semi_valid_conf/stc.conf.d/50.conf.wrong-extension @@ -2,5 +2,5 @@ # file with wrong extension - won't be picked up. If it does, the # it will cause a duplicate-error since in_pri_50 already exists [Filesystem in_pri_50] -Device=/dev/sda +FilesystemDevice=/dev/sda FilesystemMountPath=/mnt/50 diff --git a/stc/testdata/semi_valid_conf/stc.conf.d/90.conf b/stc/testdata/semi_valid_conf/stc.conf.d/90.conf index ddf3c07..8b34f9a 100644 --- a/stc/testdata/semi_valid_conf/stc.conf.d/90.conf +++ b/stc/testdata/semi_valid_conf/stc.conf.d/90.conf @@ -1,9 +1,9 @@ [Filesystem in_pri_90] -Device=/dev/sda +FilesystemDevice=/dev/sda FilesystemMountPath=/mnt/90 # this is for testing that we replace the previous entry (see also 91.conf) [Filesystem multiple_instances_same_id] -Device=/dev/multiple_instances_same_id/first +FilesystemDevice=/dev/multiple_instances_same_id/first FilesystemMountPath=/mnt/m_first diff --git a/stc/testdata/semi_valid_conf/stc.conf.d/91.conf b/stc/testdata/semi_valid_conf/stc.conf.d/91.conf index 8fbb1b9..e8b1bdc 100644 --- a/stc/testdata/semi_valid_conf/stc.conf.d/91.conf +++ b/stc/testdata/semi_valid_conf/stc.conf.d/91.conf @@ -1,4 +1,4 @@ # this is for testing that we replace the previous entry (see also 90.conf) [Filesystem multiple_instances_same_id] -Device=/dev/multiple_instances_same_id/second +FilesystemDevice=/dev/multiple_instances_same_id/second FilesystemMountPath=/mnt/m_second |