summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/gfdb/gfdb_data_store_helper.h
blob: 7b4b0ae6aa14065f673de14d188d49fd1fe5f6a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
   Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com>
   This file is part of GlusterFS.

   This file is licensed to you under your choice of the GNU Lesser
   General Public License, version 3 or any later version (LGPLv3 or
   later), or the GNU General Public License, version 2 (GPLv2), in all
   cases as published by the Free Software Foundation.
*/
#ifndef __GFDB_DATA_STORE_HELPER_H
#define __GFDB_DATA_STORE_HELPER_H

#include <time.h>
#include <sys/time.h>
#include <string.h>
#include <fcntl.h>

#include "common-utils.h"
#include "compat-uuid.h"
#include "gfdb_mem-types.h"
#include "dict.h"
#include "byte-order.h"
#include "libglusterfs-messages.h"

#define GFDB_DATA_STORE "gfdbdatastore"

/*******************************************************************************
 *
 *                     Query related data structure and functions
 *
 * ****************************************************************************/

#ifdef NAME_MAX
#define GF_NAME_MAX NAME_MAX
#else
#define GF_NAME_MAX 255
#endif

/*Structure to hold the link information*/
typedef struct gfdb_link_info {
    uuid_t pargfid;
    char file_name[GF_NAME_MAX];
    struct list_head list;
} gfdb_link_info_t;

/*Structure used for querying purpose*/
typedef struct gfdb_query_record {
    uuid_t gfid;
    /*This is the hardlink list*/
    struct list_head link_list;
    int link_count;
} gfdb_query_record_t;

/*Create a single link info structure*/
gfdb_link_info_t *
gfdb_link_info_new();
typedef gfdb_link_info_t *(*gfdb_link_info_new_t)();

/*Destroy a link info structure*/
void
gfdb_link_info_free(gfdb_link_info_t *gfdb_link_info);
typedef void (*gfdb_link_info_free_t)(gfdb_link_info_t *gfdb_link_info);

/* Function to create the query_record */
gfdb_query_record_t *
gfdb_query_record_new();
typedef gfdb_query_record_t *(*gfdb_query_record_new_t)();

/* Function to add linkinfo to query record */
int
gfdb_add_link_to_query_record(gfdb_query_record_t *gfdb_query_record,
                              uuid_t pgfid, char *base_name);
typedef int (*gfdb_add_link_to_query_record_t)(gfdb_query_record_t *, uuid_t,
                                               char *);

/*Function to destroy query record*/
void
gfdb_query_record_free(gfdb_query_record_t *gfdb_query_record);
typedef void (*gfdb_query_record_free_t)(gfdb_query_record_t *);

/* Function to write query record to file */
int
gfdb_write_query_record(int fd, gfdb_query_record_t *gfdb_query_record);
typedef int (*gfdb_write_query_record_t)(int, gfdb_query_record_t *);

/* Function to read query record from file.
 * Allocates memory to query record and return 0 when successful
 * Return -1 when failed.
 * Return 0 when EOF.
 * */
int
gfdb_read_query_record(int fd, gfdb_query_record_t **gfdb_query_record);
typedef int (*gfdb_read_query_record_t)(int, gfdb_query_record_t **);

#endif