LCOV - code coverage report
Current view: top level - misc/kabi/lvm2.git/lib/error - errseg.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 13 34 38.2 %
Date: 2010-04-13 Functions: 2 7 28.6 %
Branches: 1 10 10.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
       3                 :            :  *
       4                 :            :  * This file is part of LVM2.
       5                 :            :  *
       6                 :            :  * This copyrighted material is made available to anyone wishing to use,
       7                 :            :  * modify, copy, or redistribute it subject to the terms and conditions
       8                 :            :  * of the GNU Lesser General Public License v.2.1.
       9                 :            :  *
      10                 :            :  * You should have received a copy of the GNU Lesser General Public License
      11                 :            :  * along with this program; if not, write to the Free Software Foundation,
      12                 :            :  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      13                 :            :  */
      14                 :            : 
      15                 :            : #include "lib.h"
      16                 :            : #include "toolcontext.h"
      17                 :            : #include "segtype.h"
      18                 :            : #include "display.h"
      19                 :            : #include "text_export.h"
      20                 :            : #include "text_import.h"
      21                 :            : #include "config.h"
      22                 :            : #include "str_list.h"
      23                 :            : #include "targets.h"
      24                 :            : #include "lvm-string.h"
      25                 :            : #include "activate.h"
      26                 :            : #include "str_list.h"
      27                 :            : #include "metadata.h"
      28                 :            : 
      29                 :          0 : static const char *_errseg_name(const struct lv_segment *seg)
      30                 :            : {
      31                 :          0 :         return seg->segtype->name;
      32                 :            : }
      33                 :            : 
      34                 :          0 : static int _errseg_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
      35                 :            : {
      36                 :          0 :         seg1->len += seg2->len;
      37                 :          0 :         seg1->area_len += seg2->area_len;
      38                 :            : 
      39                 :          0 :         return 1;
      40                 :            : }
      41                 :            : 
      42                 :            : #ifdef DEVMAPPER_SUPPORT
      43                 :          0 : static int _errseg_add_target_line(struct dev_manager *dm __attribute((unused)),
      44                 :            :                                 struct dm_pool *mem __attribute((unused)),
      45                 :            :                                 struct cmd_context *cmd __attribute((unused)),
      46                 :            :                                 void **target_state __attribute((unused)),
      47                 :            :                                 struct lv_segment *seg __attribute((unused)),
      48                 :            :                                 struct dm_tree_node *node, uint64_t len,
      49                 :            :                                 uint32_t *pvmove_mirror_count __attribute((unused)))
      50                 :            : {
      51                 :          0 :         return dm_tree_node_add_error_target(node, len);
      52                 :            : }
      53                 :            : 
      54                 :          0 : static int _errseg_target_present(struct cmd_context *cmd,
      55                 :            :                                   const struct lv_segment *seg __attribute((unused)),
      56                 :            :                                   unsigned *attributes __attribute((unused)))
      57                 :            : {
      58                 :            :         static int _errseg_checked = 0;
      59                 :            :         static int _errseg_present = 0;
      60                 :            : 
      61                 :            :         /* Reported truncated in older kernels */
      62 [ #  #  #  #  # :          0 :         if (!_errseg_checked &&
                      # ]
      63                 :          0 :             (target_present(cmd, "error", 0) ||
      64                 :          0 :              target_present(cmd, "erro", 0)))
      65                 :          0 :                 _errseg_present = 1;
      66                 :            : 
      67                 :          0 :         _errseg_checked = 1;
      68                 :          0 :         return _errseg_present;
      69                 :            : }
      70                 :            : #endif
      71                 :            : 
      72                 :          0 : static int _errseg_modules_needed(struct dm_pool *mem,
      73                 :            :                                   const struct lv_segment *seg __attribute((unused)),
      74                 :            :                                   struct dm_list *modules)
      75                 :            : {
      76         [ #  # ]:          0 :         if (!str_list_add(mem, modules, "error")) {
      77                 :          0 :                 log_error("error module string list allocation failed");
      78                 :          0 :                 return 0;
      79                 :            :         }
      80                 :            : 
      81                 :          0 :         return 1;
      82                 :            : }
      83                 :            : 
      84                 :          3 : static void _errseg_destroy(const struct segment_type *segtype)
      85                 :            : {
      86                 :          3 :         dm_free((void *)segtype);
      87                 :          3 : }
      88                 :            : 
      89                 :            : static struct segtype_handler _error_ops = {
      90                 :            :         .name = _errseg_name,
      91                 :            :         .merge_segments = _errseg_merge_segments,
      92                 :            : #ifdef DEVMAPPER_SUPPORT
      93                 :            :         .add_target_line = _errseg_add_target_line,
      94                 :            :         .target_present = _errseg_target_present,
      95                 :            : #endif
      96                 :            :         .modules_needed = _errseg_modules_needed,
      97                 :            :         .destroy = _errseg_destroy,
      98                 :            : };
      99                 :            : 
     100                 :          3 : struct segment_type *init_error_segtype(struct cmd_context *cmd)
     101                 :            : {
     102                 :          3 :         struct segment_type *segtype = dm_malloc(sizeof(*segtype));
     103                 :            : 
     104         [ -  + ]:          3 :         if (!segtype)
     105                 :          0 :                 return_NULL;
     106                 :            : 
     107                 :          3 :         segtype->cmd = cmd;
     108                 :          3 :         segtype->ops = &_error_ops;
     109                 :          3 :         segtype->name = "error";
     110                 :          3 :         segtype->private = NULL;
     111                 :          3 :         segtype->flags = SEG_CAN_SPLIT | SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
     112                 :            : 
     113                 :          3 :         log_very_verbose("Initialised segtype: %s", segtype->name);
     114                 :            : 
     115                 :          3 :         return segtype;
     116                 :            : }

Generated by: LCOV version 1.8