L4Re/departure

Annotated libe2access/include/e2access/image.h

255:8145967ef012
2022-02-17 Paul Boddie Added support for removing files with e2access.
paul@181 1
/*
paul@181 2
 * Filesystem image access functions.
paul@181 3
 *
paul@236 4
 * Copyright (C) 2019, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
paul@181 5
 *
paul@181 6
 * This program is free software; you can redistribute it and/or
paul@181 7
 * modify it under the terms of the GNU General Public License as
paul@181 8
 * published by the Free Software Foundation; either version 2 of
paul@181 9
 * the License, or (at your option) any later version.
paul@181 10
 *
paul@181 11
 * This program is distributed in the hope that it will be useful,
paul@181 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@181 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@181 14
 * GNU General Public License for more details.
paul@181 15
 *
paul@181 16
 * You should have received a copy of the GNU General Public License
paul@181 17
 * along with this program; if not, write to the Free Software
paul@181 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@181 19
 * Boston, MA  02110-1301, USA
paul@181 20
 */
paul@181 21
paul@181 22
#ifndef __IMAGE_H__
paul@181 23
#define __IMAGE_H__
paul@181 24
paul@181 25
#include <ext2fs/ext2fs.h>
paul@226 26
#include <sys/stat.h>
paul@181 27
paul@181 28
#ifdef __cplusplus
paul@181 29
extern "C" {
paul@181 30
#endif
paul@181 31
paul@243 32
/* Filesystem operations. */
paul@243 33
paul@249 34
errcode_t image_access_by_path(ext2_filsys fs, const char *path,
paul@249 35
                               errcode_t (*op)(ext2_filsys, ext2_ino_t),
paul@249 36
                               ext2_ino_t *ino);
paul@249 37
paul@181 38
errcode_t image_create_file(ext2_filsys fs, ext2_ino_t ino_target,
paul@181 39
                            const char *basename, __u16 mode,
paul@181 40
                            __u16 uid, __u16 gid, ext2_ino_t *ino_file);
paul@181 41
paul@249 42
errcode_t image_dir_empty_by_inode(ext2_filsys fs, ext2_ino_t ino);
paul@249 43
paul@249 44
errcode_t image_dir_empty_by_path(ext2_filsys fs, const char *path,
paul@249 45
                                  ext2_ino_t *ino);
paul@249 46
paul@249 47
errcode_t image_dir_get_parent(ext2_filsys fs, ext2_ino_t ino,
paul@249 48
                               ext2_ino_t *ino_parent);
paul@249 49
paul@236 50
int image_file_type(int mode);
paul@236 51
paul@181 52
errcode_t image_find_next(ext2_filsys fs, ext2_ino_t ino_dir,
paul@181 53
                          const char **basename, char *buf, ext2_ino_t *ino);
paul@181 54
paul@181 55
errcode_t image_find_path(ext2_filsys fs, const char **pathname,
paul@181 56
                          ext2_ino_t *ino);
paul@181 57
paul@181 58
errcode_t image_find_file(ext2_filsys fs, const char *dirname,
paul@181 59
                          const char *basename, ext2_ino_t *ino);
paul@181 60
paul@181 61
errcode_t image_inode(ext2_filsys fs, const char *pathname,
paul@181 62
                      struct ext2_inode *inode);
paul@181 63
paul@253 64
errcode_t image_inode_refcount_update(ext2_filsys fs, ext2_ino_t ino,
paul@253 65
                                      int change);
paul@249 66
paul@226 67
errcode_t image_list_dir(ext2_filsys fs, const char *path,
paul@226 68
                         int (*proc)(struct ext2_dir_entry *, int, int, char *,
paul@226 69
                                     void *),
paul@226 70
                         void *data);
paul@226 71
paul@181 72
errcode_t image_make_dir(ext2_filsys fs, ext2_ino_t ino_dir,
paul@181 73
                         const char *basename, __u16 mode,
paul@181 74
                         __u16 uid, __u16 gid, ext2_ino_t *ino);
paul@181 75
paul@181 76
errcode_t image_make_next_dir(ext2_filsys fs, ext2_ino_t ino_dir,
paul@181 77
                              const char **basename, __u16 mode, __u16 uid,
paul@181 78
                              __u16 gid, ext2_ino_t *ino);
paul@181 79
paul@181 80
errcode_t image_make_dirs(ext2_filsys fs, const char **pathname,
paul@181 81
                          ext2_ino_t ino_dir, __u16 mode, __u16 uid,
paul@181 82
                          __u16 gid);
paul@181 83
paul@235 84
errcode_t image_remove_by_inode(ext2_filsys fs, ext2_ino_t ino);
paul@235 85
paul@249 86
errcode_t image_remove_by_path(ext2_filsys fs, const char *path,
paul@249 87
                               ext2_ino_t *ino);
paul@248 88
paul@236 89
errcode_t image_rename(ext2_filsys fs, ext2_ino_t source,
paul@236 90
                       ext2_ino_t source_parent, const char *source_basename,
paul@236 91
                       ext2_ino_t target_parent, const char *target_basename);
paul@236 92
paul@181 93
void image_set_metadata(struct ext2_inode *inode, int clean, __u16 mode,
paul@181 94
                        __u16 uid, __u16 gid);
paul@181 95
paul@181 96
errcode_t image_stat_inode(ext2_filsys fs, ext2_ino_t ino, struct stat *st);
paul@181 97
paul@231 98
errcode_t image_unlink_by_name(ext2_filsys fs, ext2_ino_t ino_parent,
paul@231 99
                               const char *basename);
paul@231 100
paul@243 101
errcode_t image_unlink_by_path(ext2_filsys fs, const char *path);
paul@243 102
paul@231 103
errcode_t image_unlink_by_inode(ext2_filsys fs, ext2_ino_t ino_parent,
paul@231 104
                                ext2_ino_t ino);
paul@231 105
paul@243 106
/* Presence and type tests. */
paul@243 107
paul@243 108
int image_exists(ext2_filsys fs, const char *name);
paul@243 109
paul@181 110
int _image_isdir(ext2_filsys fs, ext2_ino_t ino);
paul@181 111
paul@181 112
int image_isdir(ext2_filsys fs, const char *name);
paul@181 113
paul@255 114
int image_isdir_by_path(ext2_filsys fs, const char *name, ext2_ino_t *ino);
paul@255 115
paul@181 116
int _image_isfile(ext2_filsys fs, ext2_ino_t ino);
paul@181 117
paul@181 118
int image_isfile(ext2_filsys fs, const char *name);
paul@181 119
paul@255 120
int image_isfile_by_path(ext2_filsys fs, const char *name, ext2_ino_t *ino);
paul@255 121
paul@181 122
#ifdef __cplusplus
paul@181 123
}
paul@181 124
#endif
paul@181 125
paul@181 126
paul@181 127
#endif /* __IMAGE_H__ */
paul@249 128
paul@249 129
/* vim: tabstop=4 expandtab shiftwidth=4
paul@249 130
*/