| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include "label-util.h" |
| 4 |
|
| 5 |
static const LabelOps *label_ops = NULL; |
| 6 |
|
| 7 |
int label_ops_set(const LabelOps *ops) { |
| 8 |
assert(ops); |
| 9 |
|
| 10 |
if (label_ops) |
| 11 |
return -EBUSY; |
| 12 |
|
| 13 |
label_ops = ops; |
| 14 |
return 0; |
| 15 |
} |
| 16 |
|
| 17 |
void label_ops_reset(void) { |
| 18 |
label_ops = NULL; |
| 19 |
} |
| 20 |
|
| 21 |
int label_ops_pre(int dir_fd, const char *path, mode_t mode) { |
| 22 |
if (!label_ops || !label_ops->pre) |
| 23 |
return 0; |
| 24 |
|
| 25 |
return label_ops->pre(dir_fd, path, mode); |
| 26 |
} |
| 27 |
|
| 28 |
int label_ops_post(int dir_fd, const char *path, bool created) { |
| 29 |
if (!label_ops || !label_ops->post) |
| 30 |
return 0; |
| 31 |
|
| 32 |
return label_ops->post(dir_fd, path, created); |
| 33 |
} |