~wb-munzinger/+junk/ocfs2-tools

« back to all changes in this revision

Viewing changes to libocfs2/checkhb.c

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2009-07-06 07:26:30 UTC
  • mfrom: (1.1.7 upstream) (0.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090706072630-59335sl51k3rvu74
Tags: 1.4.2-1
* New upstream release (Closes: #535471).
* Drop patch for limits.h, included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include <sys/stat.h>
37
37
#include <signal.h>
38
38
 
39
 
#include "ocfs2.h"
40
 
#include "ocfs2_fs.h"
41
 
#include "ocfs1_fs_compat.h"
42
 
 
43
 
static errcode_t ocfs2_read_slotmap (ocfs2_filesys *fs, uint8_t *node_nums)
44
 
{
45
 
        errcode_t ret = 0;
46
 
        char *slotbuf = NULL;
47
 
        int slotbuf_len;
48
 
        char *slotmap = ocfs2_system_inodes[SLOT_MAP_SYSTEM_INODE].si_name;
49
 
        uint32_t slotmap_len;
50
 
        uint64_t slotmap_blkno;
51
 
        int16_t *slots;
52
 
        int i, j;
53
 
        uint32_t num_nodes = OCFS2_RAW_SB(fs->fs_super)->s_max_slots;
54
 
 
55
 
        slotmap_len = strlen(slotmap);
56
 
 
57
 
        ret = ocfs2_lookup(fs, fs->fs_sysdir_blkno, slotmap, slotmap_len,
58
 
                           NULL, &slotmap_blkno);
59
 
        if (ret)
60
 
                return ret;
61
 
 
62
 
        ret =  ocfs2_read_whole_file(fs, slotmap_blkno, &slotbuf, &slotbuf_len);
63
 
        if (!ret) {
64
 
                slots = (int16_t *)slotbuf;
65
 
                for (i = 0, j = 0; i < num_nodes; ++i)
66
 
                        if (le16_to_cpu(slots[i]) != (uint16_t)OCFS2_INVALID_SLOT)
67
 
                                node_nums[j++] = le16_to_cpu(slots[i]);
68
 
        }
69
 
 
70
 
        if (slotbuf)
71
 
                ocfs2_free(&slotbuf);
72
 
 
73
 
        return ret;
74
 
}
 
39
 
 
40
#include "ocfs2/byteorder.h"
 
41
#include "ocfs2/ocfs2.h"
 
42
#include "ocfs2-kernel/ocfs1_fs_compat.h"
 
43
 
75
44
 
76
45
/*
77
46
 * ocfs2_check_heartbeats() check if the list of ocfs2 devices are
93
62
        struct list_head *pos;
94
63
        ocfs2_devices *dev = NULL;
95
64
        char *device= NULL;
96
 
        int open_flags;
 
65
        int open_flags, i;
97
66
 
98
67
        list_for_each(pos, dev_list) {
99
68
                dev = list_entry(pos, ocfs2_devices, list);
122
91
                }
123
92
 
124
93
                /* get label/uuid for ocfs2 */
125
 
                dev->max_slots = OCFS2_RAW_SB(fs->fs_super)->s_max_slots;
126
94
                memcpy(dev->label, OCFS2_RAW_SB(fs->fs_super)->s_label,
127
95
                       sizeof(dev->label));
128
96
                memcpy(dev->uuid, OCFS2_RAW_SB(fs->fs_super)->s_uuid,
129
97
                       sizeof(dev->uuid));
130
98
 
131
 
                ret = ocfs2_malloc((sizeof(uint8_t) * dev->max_slots),
132
 
                                   &dev->node_nums);
133
 
                if (ret)
134
 
                        goto bail;
135
 
 
136
 
                memset(dev->node_nums, OCFS2_MAX_SLOTS,
137
 
                       (sizeof(uint8_t) * dev->max_slots));
138
 
 
139
99
                if (dev->hb_dev)
140
100
                        goto close;
141
101
 
142
102
                /* read slotmap to get nodes on which the volume is mounted */
143
 
                ret = ocfs2_read_slotmap(fs, dev->node_nums);
 
103
                ret = ocfs2_load_slot_map(fs, &dev->map);
144
104
                if (ret) {
145
105
                        dev->errcode = ret;
146
106
                        ret = 0;
147
107
                } else {
148
 
                        if (dev->node_nums[0] != OCFS2_MAX_SLOTS)
149
 
                                dev->mount_flags |= OCFS2_MF_MOUNTED_CLUSTER;
 
108
                        for (i = 0; i < dev->map->md_num_slots; i++) {
 
109
                                if (dev->map->md_slots[i].sd_valid) {
 
110
                                        dev->mount_flags |= OCFS2_MF_MOUNTED_CLUSTER;
 
111
                                        break;
 
112
                                }
 
113
                        }
150
114
                }
151
115
close:
152
116
                ocfs2_close(fs);
168
132
        char buf[512];
169
133
        struct ocfs1_vol_label *v1_lbl;
170
134
 
171
 
        fd = open(device, O_RDONLY);
 
135
        fd = open64(device, O_RDONLY);
172
136
        if (fd == -1)
173
137
                goto bail;
174
138