summaryrefslogtreecommitdiff
path: root/lib/error/errseg.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/error/errseg.c')
-rw-r--r--lib/error/errseg.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/lib/error/errseg.c b/lib/error/errseg.c
index 179f1a6..bbdf235 100644
--- a/lib/error/errseg.c
+++ b/lib/error/errseg.c
@@ -9,22 +9,18 @@
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "lib.h"
-#include "toolcontext.h"
-#include "segtype.h"
-#include "display.h"
-#include "config.h"
-#include "str_list.h"
-#include "activate.h"
-#include "str_list.h"
-
-static const char *_errseg_name(const struct lv_segment *seg)
-{
- return seg->segtype->name;
-}
+#include "base/memory/zalloc.h"
+#include "lib/misc/lib.h"
+#include "lib/commands/toolcontext.h"
+#include "lib/metadata/segtype.h"
+#include "lib/display/display.h"
+#include "lib/config/config.h"
+#include "lib/datastruct/str_list.h"
+#include "lib/activate/activate.h"
+#include "lib/datastruct/str_list.h"
static int _errseg_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
{
@@ -54,56 +50,56 @@ static int _errseg_target_present(struct cmd_context *cmd,
static int _errseg_checked = 0;
static int _errseg_present = 0;
+ if (!activation())
+ return 0;
+
/* Reported truncated in older kernels */
- if (!_errseg_checked &&
- (target_present(cmd, "error", 0) ||
- target_present(cmd, "erro", 0)))
- _errseg_present = 1;
+ if (!_errseg_checked) {
+ _errseg_checked = 1;
+ _errseg_present = target_present(cmd, TARGET_NAME_ERROR, 0) ||
+ target_present(cmd, TARGET_NAME_ERROR_OLD, 0);
+ }
- _errseg_checked = 1;
return _errseg_present;
}
-#endif
static int _errseg_modules_needed(struct dm_pool *mem,
const struct lv_segment *seg __attribute__((unused)),
struct dm_list *modules)
{
- if (!str_list_add(mem, modules, "error")) {
+ if (!str_list_add(mem, modules, MODULE_NAME_ERROR)) {
log_error("error module string list allocation failed");
return 0;
}
return 1;
}
+#endif
static void _errseg_destroy(struct segment_type *segtype)
{
- dm_free(segtype);
+ free(segtype);
}
static struct segtype_handler _error_ops = {
- .name = _errseg_name,
.merge_segments = _errseg_merge_segments,
#ifdef DEVMAPPER_SUPPORT
.add_target_line = _errseg_add_target_line,
.target_present = _errseg_target_present,
-#endif
.modules_needed = _errseg_modules_needed,
+#endif
.destroy = _errseg_destroy,
};
struct segment_type *init_error_segtype(struct cmd_context *cmd)
{
- struct segment_type *segtype = dm_zalloc(sizeof(*segtype));
+ struct segment_type *segtype = zalloc(sizeof(*segtype));
if (!segtype)
return_NULL;
- segtype->cmd = cmd;
segtype->ops = &_error_ops;
- segtype->name = "error";
- segtype->private = NULL;
+ segtype->name = SEG_TYPE_NAME_ERROR;
segtype->flags = SEG_CAN_SPLIT | SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
log_very_verbose("Initialised segtype: %s", segtype->name);