dpkg (1.18.25) stretch; urgency=medium
[dpkg] / lib / dpkg / file.h
CommitLineData
1479465f
GJ
1/*
2 * libdpkg - Debian packaging suite library routines
3 * file.h - file handling routines
4 *
5 * Copyright © 2008-2010 Guillem Jover <guillem@debian.org>
6 *
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef LIBDPKG_FILE_H
22#define LIBDPKG_FILE_H
23
24#include <sys/types.h>
25
26#include <stdbool.h>
27
28#include <dpkg/macros.h>
29
30DPKG_BEGIN_DECLS
31
32/**
33 * @defgroup file File handling
34 * @ingroup dpkg-internal
35 * @{
36 */
37
38struct file_stat {
39 uid_t uid;
40 gid_t gid;
41 mode_t mode;
42
43 /* Used by dpkg-statoverride when parsing the database to preserve the
44 * user and group names in case the system does not know about them. */
45 char *uname;
46 char *gname;
47};
48
49void file_copy_perms(const char *src, const char *dst);
50
51enum file_lock_flags {
52 FILE_LOCK_NOWAIT,
53 FILE_LOCK_WAIT,
54};
55
56bool file_is_locked(int lockfd, const char *filename);
57void file_lock(int *lockfd, enum file_lock_flags flags, const char *filename,
58 const char *desc);
59void file_unlock(int fd, const char *desc);
60void file_show(const char *filename);
61
62/** @} */
63
64DPKG_END_DECLS
65
66#endif /* LIBDPKG_FILE_H */