LCOV - code coverage report
Current view: top level - fs/btrfs - orphan.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 26 0.0 %
Date: 2014-02-18 Functions: 0 3 0.0 %
Branches: 0 10 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (C) 2008 Red Hat.  All rights reserved.
       3                 :            :  *
       4                 :            :  * This program is free software; you can redistribute it and/or
       5                 :            :  * modify it under the terms of the GNU General Public
       6                 :            :  * License v2 as published by the Free Software Foundation.
       7                 :            :  *
       8                 :            :  * This program is distributed in the hope that it will be useful,
       9                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      10                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      11                 :            :  * General Public License for more details.
      12                 :            :  *
      13                 :            :  * You should have received a copy of the GNU General Public
      14                 :            :  * License along with this program; if not, write to the
      15                 :            :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      16                 :            :  * Boston, MA 021110-1307, USA.
      17                 :            :  */
      18                 :            : 
      19                 :            : #include "ctree.h"
      20                 :            : #include "disk-io.h"
      21                 :            : 
      22                 :          0 : int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
      23                 :            :                              struct btrfs_root *root, u64 offset)
      24                 :            : {
      25                 :            :         struct btrfs_path *path;
      26                 :            :         struct btrfs_key key;
      27                 :            :         int ret = 0;
      28                 :            : 
      29                 :          0 :         key.objectid = BTRFS_ORPHAN_OBJECTID;
      30                 :            :         btrfs_set_key_type(&key, BTRFS_ORPHAN_ITEM_KEY);
      31                 :          0 :         key.offset = offset;
      32                 :            : 
      33                 :          0 :         path = btrfs_alloc_path();
      34         [ #  # ]:          0 :         if (!path)
      35                 :            :                 return -ENOMEM;
      36                 :            : 
      37                 :            :         ret = btrfs_insert_empty_item(trans, root, path, &key, 0);
      38                 :            : 
      39                 :          0 :         btrfs_free_path(path);
      40                 :          0 :         return ret;
      41                 :            : }
      42                 :            : 
      43                 :          0 : int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
      44                 :            :                           struct btrfs_root *root, u64 offset)
      45                 :            : {
      46                 :            :         struct btrfs_path *path;
      47                 :            :         struct btrfs_key key;
      48                 :            :         int ret = 0;
      49                 :            : 
      50                 :          0 :         key.objectid = BTRFS_ORPHAN_OBJECTID;
      51                 :            :         btrfs_set_key_type(&key, BTRFS_ORPHAN_ITEM_KEY);
      52                 :          0 :         key.offset = offset;
      53                 :            : 
      54                 :          0 :         path = btrfs_alloc_path();
      55         [ #  # ]:          0 :         if (!path)
      56                 :            :                 return -ENOMEM;
      57                 :            : 
      58                 :          0 :         ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
      59         [ #  # ]:          0 :         if (ret < 0)
      60                 :            :                 goto out;
      61         [ #  # ]:          0 :         if (ret) { /* JDM: Really? */
      62                 :            :                 ret = -ENOENT;
      63                 :            :                 goto out;
      64                 :            :         }
      65                 :            : 
      66                 :            :         ret = btrfs_del_item(trans, root, path);
      67                 :            : 
      68                 :            : out:
      69                 :          0 :         btrfs_free_path(path);
      70                 :          0 :         return ret;
      71                 :            : }
      72                 :            : 
      73                 :          0 : int btrfs_find_orphan_item(struct btrfs_root *root, u64 offset)
      74                 :            : {
      75                 :            :         struct btrfs_path *path;
      76                 :            :         struct btrfs_key key;
      77                 :            :         int ret;
      78                 :            : 
      79                 :          0 :         key.objectid = BTRFS_ORPHAN_OBJECTID;
      80                 :          0 :         key.type = BTRFS_ORPHAN_ITEM_KEY;
      81                 :          0 :         key.offset = offset;
      82                 :            : 
      83                 :          0 :         path = btrfs_alloc_path();
      84         [ #  # ]:          0 :         if (!path)
      85                 :            :                 return -ENOMEM;
      86                 :            : 
      87                 :          0 :         ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
      88                 :            : 
      89                 :          0 :         btrfs_free_path(path);
      90                 :          0 :         return ret;
      91                 :            : }

Generated by: LCOV version 1.9