summaryrefslogtreecommitdiffstats
path: root/xlators/debug/sink/src/sink.c
blob: dfd5685a969753159010e15003d5376ece7d7a97 (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
/*
   Copyright (c) 2017 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.
*/

#include "xlator.h"
#include "defaults.h"

int32_t
init (xlator_t *this)
{
        return 0;
}

void
fini (xlator_t *this)
{
        return;
}

/*
 * notify - when parent sends PARENT_UP, send CHILD_UP event from here
 */
int32_t
notify (xlator_t *this, int32_t event, void *data, ...)
{
        switch (event) {
        case GF_EVENT_PARENT_UP:
                /* Tell the parent that this xlator is up */
                default_notify (this, GF_EVENT_CHILD_UP, data);
                break;
        case GF_EVENT_PARENT_DOWN:
                /* Tell the parent that this xlator is down */
                default_notify (this, GF_EVENT_CHILD_DOWN, data);
                break;
        default:
                break;
        }

        return 0;
}

/*
 * A lookup on "/" is done while mounting or glfs_init() is performed. This
 * needs to return a valid directory for the root of the mountpoint.
 *
 * In case this xlator is used for more advanced debugging, it will need to be
 * extended to support different LOOKUPs too.
 */
static int32_t
sink_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
        struct iatt stbuf = { 0, };
        struct iatt postparent = { 0, };

        /* the root of the volume always need to be a directory */
        stbuf.ia_type = IA_IFDIR;

        STACK_UNWIND_STRICT (lookup, frame, 0, 0, loc ? loc->inode : NULL,
                             &stbuf, xdata, &postparent);

        return 0;
}

struct xlator_fops fops = {
        .lookup = sink_lookup,
};

struct xlator_cbks cbks = {
};

struct volume_options options[] = {
        { .key  = {NULL} },
};