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

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
       3                 :            :  * Copyright (C) 2004-2007 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 "locking.h"
      18                 :            : #include "locking_types.h"
      19                 :            : #include "lvm-string.h"
      20                 :            : #include "activate.h"
      21                 :            : 
      22                 :            : #include <signal.h>
      23                 :            : 
      24                 :            : /*
      25                 :            :  * No locking
      26                 :            :  */
      27                 :            : 
      28                 :          0 : static void _no_fin_locking(void)
      29                 :            : {
      30                 :          0 : }
      31                 :            : 
      32                 :          0 : static void _no_reset_locking(void)
      33                 :            : {
      34                 :          0 : }
      35                 :            : 
      36                 :          0 : static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
      37                 :            :                              uint32_t flags)
      38                 :            : {
      39      [ #  #  # ]:          0 :         switch (flags & LCK_SCOPE_MASK) {
      40                 :            :         case LCK_VG:
      41                 :          0 :                 break;
      42                 :            :         case LCK_LV:
      43 [ #  #  #  #  # :          0 :                 switch (flags & LCK_TYPE_MASK) {
                      # ]
      44                 :            :                 case LCK_NULL:
      45                 :          0 :                         return lv_deactivate(cmd, resource);
      46                 :            :                 case LCK_UNLOCK:
      47                 :          0 :                         return lv_resume_if_active(cmd, resource);
      48                 :            :                 case LCK_READ:
      49                 :          0 :                         return lv_activate_with_filter(cmd, resource, 0);
      50                 :            :                 case LCK_WRITE:
      51                 :          0 :                         return lv_suspend_if_active(cmd, resource);
      52                 :            :                 case LCK_EXCL:
      53                 :          0 :                         return lv_activate_with_filter(cmd, resource, 1);
      54                 :            :                 default:
      55                 :            :                         break;
      56                 :            :                 }
      57                 :          0 :                 break;
      58                 :            :         default:
      59                 :          0 :                 log_error("Unrecognised lock scope: %d",
      60                 :            :                           flags & LCK_SCOPE_MASK);
      61                 :          0 :                 return 0;
      62                 :            :         }
      63                 :            : 
      64                 :          0 :         return 1;
      65                 :            : }
      66                 :            : 
      67                 :          0 : static int _readonly_lock_resource(struct cmd_context *cmd,
      68                 :            :                                    const char *resource,
      69                 :            :                                    uint32_t flags)
      70                 :            : {
      71 [ #  # ][ #  # ]:          0 :         if ((flags & LCK_TYPE_MASK) == LCK_WRITE &&
         [ #  # ][ #  # ]
      72                 :          0 :             (flags & LCK_SCOPE_MASK) == LCK_VG &&
      73                 :          0 :             !(flags & LCK_CACHE) &&
      74                 :          0 :             strcmp(resource, VG_GLOBAL)) {
      75                 :          0 :                 log_error("Write locks are prohibited with read-only locking.");
      76                 :          0 :                 return 0;
      77                 :            :         }
      78                 :            : 
      79                 :          0 :         return _no_lock_resource(cmd, resource, flags);
      80                 :            : }
      81                 :            : 
      82                 :          0 : int init_no_locking(struct locking_type *locking, struct cmd_context *cmd __attribute((unused)))
      83                 :            : {
      84                 :          0 :         locking->lock_resource = _no_lock_resource;
      85                 :          0 :         locking->reset_locking = _no_reset_locking;
      86                 :          0 :         locking->fin_locking = _no_fin_locking;
      87                 :          0 :         locking->flags = LCK_CLUSTERED;
      88                 :            : 
      89                 :          0 :         return 1;
      90                 :            : }
      91                 :            : 
      92                 :          0 : int init_readonly_locking(struct locking_type *locking, struct cmd_context *cmd __attribute((unused)))
      93                 :            : {
      94                 :          0 :         locking->lock_resource = _readonly_lock_resource;
      95                 :          0 :         locking->reset_locking = _no_reset_locking;
      96                 :          0 :         locking->fin_locking = _no_fin_locking;
      97                 :          0 :         locking->flags = 0;
      98                 :            : 
      99                 :          0 :         return 1;
     100                 :            : }

Generated by: LCOV version 1.8