btrfs-progs: convert: move duplicated acl code to common header
[platform/upstream/btrfs-progs.git] / convert / source-reiserfs.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public
4  * License v2 as published by the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9  * General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the
13  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
14  * Boston, MA 021110-1307, USA.
15  */
16
17 #ifndef __BTRFS_CONVERT_SOURCE_REISERFS_H__
18 #define __BTRFS_CONVERT_SOURCE_REISERFS_H__
19
20 #if BTRFSCONVERT_REISERFS
21
22 #include "kerncompat.h"
23 #include <reiserfs/misc.h>
24 #include <reiserfs/io.h>
25 #include <reiserfs/reiserfs_lib.h>
26 #include <reiserfs/reiserfs_fs.h>
27 #include <linux/kdev_t.h>
28 #include "convert/source-fs.h"
29
30 #define REISERFS_ACL_VERSION    0x0001
31
32 static inline int ext2_acl_count(size_t size)
33 {
34         ssize_t s;
35         size -= sizeof(ext2_acl_header);
36         s = size - 4 * sizeof(ext2_acl_entry_short);
37         if (s < 0) {
38                 if (size % sizeof(ext2_acl_entry_short))
39                         return -1;
40                 return size / sizeof(ext2_acl_entry_short);
41         } else {
42                 if (s % sizeof(ext2_acl_entry))
43                         return -1;
44                 return s / sizeof(ext2_acl_entry) + 4;
45         }
46 }
47
48 static inline dev_t new_decode_dev(u32 dev)
49 {
50         unsigned major = (dev & 0xfff00) >> 8;
51         unsigned minor = (dev & 0xff) | ((dev >> 12) & 0xfff00);
52
53         return MKDEV(major, minor);
54 }
55
56 #endif  /* BTRFSCONVERT_REISERFS */
57
58 #endif