]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/file_utils.h
spelling: timeout
[mirror_lxc.git] / src / lxc / file_utils.h
CommitLineData
37ef15bb
CB
1/* liblxcapi
2 *
3 * Copyright © 2018 Christian Brauner <christian.brauner@ubuntu.com>.
4 * Copyright © 2018 Canonical Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifndef __LXC_FILE_UTILS_H
21#define __LXC_FILE_UTILS_H
22
37ef15bb
CB
23#include <fcntl.h>
24#include <stdbool.h>
25#include <stdio.h>
26#include <sys/stat.h>
27#include <sys/types.h>
28#include <sys/vfs.h>
29#include <unistd.h>
30
31/* read and write whole files */
32extern int lxc_write_to_file(const char *filename, const void *buf,
33 size_t count, bool add_newline, mode_t mode);
34extern int lxc_read_from_file(const char *filename, void *buf, size_t count);
35
36/* send and receive buffers completely */
37extern ssize_t lxc_write_nointr(int fd, const void *buf, size_t count);
28143f88 38extern ssize_t lxc_send_nointr(int sockfd, void *buf, size_t len, int flags);
37ef15bb
CB
39extern ssize_t lxc_read_nointr(int fd, void *buf, size_t count);
40extern ssize_t lxc_read_nointr_expect(int fd, void *buf, size_t count,
41 const void *expected_buf);
de69edd1
CB
42extern ssize_t lxc_recv_nointr(int sockfd, void *buf, size_t len, int flags);
43
37ef15bb
CB
44extern bool file_exists(const char *f);
45extern int print_to_file(const char *file, const char *content);
46extern int is_dir(const char *path);
47extern int lxc_count_file_lines(const char *fn);
48extern int lxc_make_tmpfile(char *template, bool rm);
49
50/* __typeof__ should be safe to use with all compilers. */
51typedef __typeof__(((struct statfs *)NULL)->f_type) fs_type_magic;
52extern bool has_fs_type(const char *path, fs_type_magic magic_val);
53extern bool fhas_fs_type(int fd, fs_type_magic magic_val);
54extern bool is_fs_type(const struct statfs *fs, fs_type_magic magic_val);
55extern FILE *fopen_cloexec(const char *path, const char *mode);
7c4d9466
CB
56extern ssize_t lxc_sendfile_nointr(int out_fd, int in_fd, off_t *offset,
57 size_t count);
37ef15bb
CB
58
59#endif /* __LXC_FILE_UTILS_H */