LCOV - code coverage report
Current view: top level - misc/kabi/lvm2.git/lib/format_pool - pool_label.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 8 31 25.8 %
Date: 2010-04-13 Functions: 2 8 25.0 %
Branches: 1 8 12.5 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (C) 1997-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 "lib.h"
      17                 :            : #include "label.h"
      18                 :            : #include "metadata.h"
      19                 :            : #include "xlate.h"
      20                 :            : #include "disk_rep.h"
      21                 :            : #include "pool_label.h"
      22                 :            : 
      23                 :            : #include <sys/stat.h>
      24                 :            : #include <fcntl.h>
      25                 :            : 
      26                 :          0 : static void _pool_not_supported(const char *op)
      27                 :            : {
      28                 :          0 :         log_error("The '%s' operation is not supported for the pool labeller.",
      29                 :            :                   op);
      30                 :          0 : }
      31                 :            : 
      32                 :          0 : static int _pool_can_handle(struct labeller *l __attribute((unused)), void *buf, uint64_t sector)
      33                 :            : {
      34                 :            : 
      35                 :            :         struct pool_disk pd;
      36                 :            : 
      37                 :            :         /*
      38                 :            :          * POOL label must always be in first sector
      39                 :            :          */
      40         [ #  # ]:          0 :         if (sector)
      41                 :          0 :                 return 0;
      42                 :            : 
      43                 :          0 :         pool_label_in(&pd, buf);
      44                 :            : 
      45                 :            :         /* can ignore 8 rightmost bits for ondisk format check */
      46   [ #  #  #  # ]:          0 :         if ((pd.pl_magic == POOL_MAGIC) &&
      47                 :          0 :             (pd.pl_version >> 8 == POOL_VERSION >> 8))
      48                 :          0 :                 return 1;
      49                 :            : 
      50                 :          0 :         return 0;
      51                 :            : }
      52                 :            : 
      53                 :          0 : static int _pool_write(struct label *label __attribute((unused)), void *buf __attribute((unused)))
      54                 :            : {
      55                 :          0 :         _pool_not_supported("write");
      56                 :          0 :         return 0;
      57                 :            : }
      58                 :            : 
      59                 :          0 : static int _pool_read(struct labeller *l, struct device *dev, void *buf,
      60                 :            :                  struct label **label)
      61                 :            : {
      62                 :            :         struct pool_list pl;
      63                 :            : 
      64                 :          0 :         return read_pool_label(&pl, l, dev, buf, label);
      65                 :            : }
      66                 :            : 
      67                 :          0 : static int _pool_initialise_label(struct labeller *l __attribute((unused)), struct label *label)
      68                 :            : {
      69                 :          0 :         strcpy(label->type, "POOL");
      70                 :            : 
      71                 :          0 :         return 1;
      72                 :            : }
      73                 :            : 
      74                 :          0 : static void _pool_destroy_label(struct labeller *l __attribute((unused)), struct label *label __attribute((unused)))
      75                 :            : {
      76                 :          0 : }
      77                 :            : 
      78                 :          3 : static void _label_pool_destroy(struct labeller *l)
      79                 :            : {
      80                 :          3 :         dm_free(l);
      81                 :          3 : }
      82                 :            : 
      83                 :            : struct label_ops _pool_ops = {
      84                 :            :       .can_handle = _pool_can_handle,
      85                 :            :       .write = _pool_write,
      86                 :            :       .read = _pool_read,
      87                 :            :       .verify = _pool_can_handle,
      88                 :            :       .initialise_label = _pool_initialise_label,
      89                 :            :       .destroy_label = _pool_destroy_label,
      90                 :            :       .destroy = _label_pool_destroy,
      91                 :            : };
      92                 :            : 
      93                 :          3 : struct labeller *pool_labeller_create(struct format_type *fmt)
      94                 :            : {
      95                 :            :         struct labeller *l;
      96                 :            : 
      97         [ -  + ]:          3 :         if (!(l = dm_malloc(sizeof(*l)))) {
      98                 :          0 :                 log_error("Couldn't allocate labeller object.");
      99                 :          0 :                 return NULL;
     100                 :            :         }
     101                 :            : 
     102                 :          3 :         l->ops = &_pool_ops;
     103                 :          3 :         l->private = (const void *) fmt;
     104                 :            : 
     105                 :          3 :         return l;
     106                 :            : }

Generated by: LCOV version 1.8