LCOV - code coverage report
Current view: top level - misc/kabi/lvm2.git/lib/zero - zero.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 13 32 40.6 %
Date: 2010-04-13 Functions: 2 7 28.6 %
Branches: 1 6 16.7 %

           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 "metadata.h"
      27                 :            : 
      28                 :          0 : static const char *_zero_name(const struct lv_segment *seg)
      29                 :            : {
      30                 :          0 :         return seg->segtype->name;
      31                 :            : }
      32                 :            : 
      33                 :          0 : static int _zero_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
      34                 :            : {
      35                 :          0 :         seg1->len += seg2->len;
      36                 :          0 :         seg1->area_len += seg2->area_len;
      37                 :            : 
      38                 :          0 :         return 1;
      39                 :            : }
      40                 :            : 
      41                 :            : #ifdef DEVMAPPER_SUPPORT
      42                 :          0 : static int _zero_add_target_line(struct dev_manager *dm __attribute((unused)),
      43                 :            :                                  struct dm_pool *mem __attribute((unused)),
      44                 :            :                                  struct cmd_context *cmd __attribute((unused)),
      45                 :            :                                  void **target_state __attribute((unused)),
      46                 :            :                                  struct lv_segment *seg __attribute((unused)),
      47                 :            :                                  struct dm_tree_node *node,uint64_t len,
      48                 :            :                                  uint32_t *pvmove_mirror_count __attribute((unused)))
      49                 :            : {
      50                 :          0 :         return dm_tree_node_add_zero_target(node, len);
      51                 :            : }
      52                 :            : 
      53                 :          0 : static int _zero_target_present(struct cmd_context *cmd,
      54                 :            :                                 const struct lv_segment *seg __attribute((unused)),
      55                 :            :                                 unsigned *attributes __attribute((unused)))
      56                 :            : {
      57                 :            :         static int _zero_checked = 0;
      58                 :            :         static int _zero_present = 0;
      59                 :            : 
      60         [ #  # ]:          0 :         if (!_zero_checked)
      61                 :          0 :                 _zero_present = target_present(cmd, "zero", 1);
      62                 :            : 
      63                 :          0 :         _zero_checked = 1;
      64                 :            : 
      65                 :          0 :         return _zero_present;
      66                 :            : }
      67                 :            : #endif
      68                 :            : 
      69                 :          0 : static int _zero_modules_needed(struct dm_pool *mem,
      70                 :            :                                 const struct lv_segment *seg __attribute((unused)),
      71                 :            :                                 struct dm_list *modules)
      72                 :            : {
      73         [ #  # ]:          0 :         if (!str_list_add(mem, modules, "zero")) {
      74                 :          0 :                 log_error("zero module string list allocation failed");
      75                 :          0 :                 return 0;
      76                 :            :         }
      77                 :            : 
      78                 :          0 :         return 1;
      79                 :            : }
      80                 :            : 
      81                 :          3 : static void _zero_destroy(const struct segment_type *segtype)
      82                 :            : {
      83                 :          3 :         dm_free((void *) segtype);
      84                 :          3 : }
      85                 :            : 
      86                 :            : static struct segtype_handler _zero_ops = {
      87                 :            :         .name = _zero_name,
      88                 :            :         .merge_segments = _zero_merge_segments,
      89                 :            : #ifdef DEVMAPPER_SUPPORT
      90                 :            :         .add_target_line = _zero_add_target_line,
      91                 :            :         .target_present = _zero_target_present,
      92                 :            : #endif
      93                 :            :         .modules_needed = _zero_modules_needed,
      94                 :            :         .destroy = _zero_destroy,
      95                 :            : };
      96                 :            : 
      97                 :          3 : struct segment_type *init_zero_segtype(struct cmd_context *cmd)
      98                 :            : {
      99                 :          3 :         struct segment_type *segtype = dm_malloc(sizeof(*segtype));
     100                 :            : 
     101         [ -  + ]:          3 :         if (!segtype)
     102                 :          0 :                 return_NULL;
     103                 :            : 
     104                 :          3 :         segtype->cmd = cmd;
     105                 :          3 :         segtype->ops = &_zero_ops;
     106                 :          3 :         segtype->name = "zero";
     107                 :          3 :         segtype->private = NULL;
     108                 :          3 :         segtype->flags = SEG_CAN_SPLIT | SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
     109                 :            : 
     110                 :          3 :         log_very_verbose("Initialised segtype: %s", segtype->name);
     111                 :            : 
     112                 :          3 :         return segtype;
     113                 :            : }

Generated by: LCOV version 1.8