LCOV - code coverage report
Current view: top level - misc/kabi/lvm2.git/tools - lvscan.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 0 37 0.0 %
Date: 2010-04-13 Functions: 0 2 0.0 %
Branches: 0 36 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
       3                 :            :  * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
       4                 :            :  *
       5                 :            :  * This file is part of LVM2.
       6                 :            :  *
       7                 :            :  * This copyrighted material is made available to anyone wishing to use,
       8                 :            :  * modify, copy, or redistribute it subject to the terms and conditions
       9                 :            :  * of the GNU Lesser General Public License v.2.1.
      10                 :            :  *
      11                 :            :  * You should have received a copy of the GNU Lesser General Public License
      12                 :            :  * along with this program; if not, write to the Free Software Foundation,
      13                 :            :  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "tools.h"
      17                 :            : 
      18                 :          0 : static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
      19                 :            :                          void *handle __attribute((unused)))
      20                 :            : {
      21                 :            :         struct lvinfo info;
      22                 :          0 :         int lv_total = 0;
      23                 :          0 :         uint64_t lv_capacity_total = 0;
      24                 :          0 :         int inkernel, snap_active = 1;
      25                 :          0 :         struct lv_segment *snap_seg = NULL;
      26                 :            :         float snap_percent;     /* fused, fsize; */
      27                 :            :         percent_range_t percent_range;
      28                 :            : 
      29                 :            :         const char *active_str, *snapshot_str;
      30                 :            : 
      31 [ #  # ][ #  # ]:          0 :         if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
      32                 :          0 :                 return ECMD_PROCESSED;
      33                 :            : 
      34 [ #  # ][ #  # ]:          0 :         inkernel = lv_info(cmd, lv, &info, 1, 0) && info.exists;
      35         [ #  # ]:          0 :         if (lv_is_origin(lv)) {
      36         [ #  # ]:          0 :                 dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs,
      37                 :            :                                        origin_list) {
      38   [ #  #  #  # ]:          0 :                         if (inkernel &&
      39                 :          0 :                             (snap_active = lv_snapshot_percent(snap_seg->cow,
      40                 :            :                                                                &snap_percent,
      41                 :            :                                                                &percent_range)))
      42         [ #  # ]:          0 :                                 if (percent_range == PERCENT_INVALID)
      43                 :          0 :                                         snap_active = 0;
      44                 :            :                 }
      45                 :          0 :                 snap_seg = NULL;
      46         [ #  # ]:          0 :         } else if (lv_is_cow(lv)) {
      47   [ #  #  #  # ]:          0 :                 if (inkernel &&
      48                 :          0 :                     (snap_active = lv_snapshot_percent(lv, &snap_percent,
      49                 :            :                                                        &percent_range)))
      50         [ #  # ]:          0 :                         if (percent_range == PERCENT_INVALID)
      51                 :          0 :                                 snap_active = 0;
      52                 :            :         }
      53                 :            : 
      54                 :            : /* FIXME Add -D arg to skip this! */
      55 [ #  # ][ #  # ]:          0 :         if (inkernel && snap_active)
      56                 :          0 :                 active_str = "ACTIVE   ";
      57                 :            :         else
      58                 :          0 :                 active_str = "inactive ";
      59                 :            : 
      60         [ #  # ]:          0 :         if (lv_is_origin(lv))
      61                 :          0 :                 snapshot_str = "Original";
      62         [ #  # ]:          0 :         else if (lv_is_cow(lv))
      63                 :          0 :                 snapshot_str = "Snapshot";
      64                 :            :         else
      65                 :          0 :                 snapshot_str = "        ";
      66                 :            : 
      67                 :          0 :         log_print("%s%s '%s%s/%s' [%s] %s", active_str, snapshot_str,
      68                 :            :                   cmd->dev_dir, lv->vg->name, lv->name,
      69                 :            :                   display_size(cmd, lv->size),
      70                 :            :                   get_alloc_string(lv->alloc));
      71                 :            : 
      72                 :          0 :         lv_total++;
      73                 :            : 
      74                 :          0 :         lv_capacity_total += lv->size;
      75                 :            : 
      76                 :          0 :         return ECMD_PROCESSED;
      77                 :            : }
      78                 :            : 
      79                 :          0 : int lvscan(struct cmd_context *cmd, int argc, char **argv)
      80                 :            : {
      81         [ #  # ]:          0 :         if (argc) {
      82                 :          0 :                 log_error("No additional command line arguments allowed");
      83                 :          0 :                 return EINVALID_CMD_LINE;
      84                 :            :         }
      85                 :            : 
      86                 :          0 :         return process_each_lv(cmd, argc, argv, 0, NULL,
      87                 :            :                                &lvscan_single);
      88                 :            : }

Generated by: LCOV version 1.8