summaryrefslogtreecommitdiffstats
path: root/src/basic/label.c
blob: 8b084a7c05f5acfc8d6bb6699cbd2b01927fab77 (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
/* SPDX-License-Identifier: LGPL-2.1-or-later */

#include <errno.h>
#include <stddef.h>

#include "label.h"

static const LabelOps *label_ops = NULL;

int label_ops_set(const LabelOps *ops) {
        if (label_ops)
                return -EBUSY;

        label_ops = ops;
        return 0;
}

int label_ops_pre(int dir_fd, const char *path, mode_t mode) {
        if (!label_ops || !label_ops->pre)
                return 0;

        return label_ops->pre(dir_fd, path, mode);
}

int label_ops_post(int dir_fd, const char *path) {
        if (!label_ops || !label_ops->post)
                return 0;

        return label_ops->post(dir_fd, path);
}

void label_ops_reset(void) {
        label_ops = NULL;
}