]> git.tuebingen.mpg.de Git - osl.git/blob - fd.h
7fdff916cec60425719772e55bc44027f1d54f86
[osl.git] / fd.h
1 /*
2  * Copyright (C) 2006-2008 Andre Noll <maan@systemlinux.org>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /** \file fd.h exported symbols from fd.c */
8
9 int osl_open(const char *path, int flags, mode_t mode);
10 int para_opendir(const char *dirname, DIR **dir, int *cwd);
11 int para_fchdir(int fd);
12 int mmap_full_file(const char *filename, int open_mode, void **map,
13         size_t *size, int *fd_ptr);
14 int osl_munmap(void *start, size_t length);
15 int write_all(int fd, const char *buf, size_t *len);
16 int write_file(const char *filename, const void *buf, size_t size);
17 int truncate_file(const char *filename, off_t size);
18
19 /**
20  * A wrapper for mkdir(2).
21  *
22  * \param path Name of the directory to create.
23  * \param mode The permissions to use.
24  *
25  * \return Standard.
26  */
27 static inline int osl_mkdir(const char *path, mode_t mode)
28 {
29         if (!mkdir(path, mode))
30                 return 1;
31         return -ERRNO_TO_ERROR(errno);
32 }
33
34 /**
35  * A wrapper for rename(2).
36  *
37  * \param old_path The source path.
38  * \param new_path The destination path.
39  *
40  * \return Standard.
41  *
42  * \sa rename(2).
43  */
44 _static_inline_ int osl_rename(const char *old_path, const char *new_path)
45 {
46         if (rename(old_path, new_path) < 0)
47                 return -ERRNO_TO_ERROR(errno);
48         return 1;
49 }
50
51 _static_inline_ int osl_stat(const char *path, struct stat *buf)
52 {
53         if (stat(path, buf) >= 0)
54                 return 1;
55         return -ERRNO_TO_ERROR(errno);
56 }