File: rootfs.h

package info (click to toggle)
xchpst 0.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 304 kB
  • sloc: ansic: 2,792; sh: 75; makefile: 47
file content (39 lines) | stat: -rw-r--r-- 853 bytes parent folder | download
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
/* SPDX-License-Identifier: MIT */
/* SPDX-FileCopyrightText: (c) Copyright 2024 Andrew Bower <andrew@bower.uk> */

#ifndef _ROOTFS_H
#define _ROOTFS_H

enum special_mount {
 SPECIAL_PROC = 0,
 SPECIAL_MAX
};

struct mount_info {
  char *from;
  char *to;
  bool mounted;
  int rc;
};

struct pivot_state {
  int roots_dir_fd;
  int old_root_fd;
  int new_root_fd;
  char *leaf_dir;
  char *path;
};

extern struct mount_info *special_mounts[SPECIAL_MAX];

static inline struct pivot_state pivot_init(void) {
  return (struct pivot_state) { -1, -1, -1, NULL, NULL };
}

extern bool create_new_root(const char *executable, struct pivot_state *pivot_state);
bool pivot_to_new_root(struct pivot_state *pivot_state);
extern void unmount_temp_rootfs(void);
extern void free_rootfs_data(void);
extern void pivot_tidy(struct pivot_state *pivot_state);

#endif