/[path-sandbox]/trunk/libsbutil/sb_open.c
Gentoo

Contents of /trunk/libsbutil/sb_open.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 370 - (show annotations) (download) (as text)
Sun Nov 9 10:29:58 2008 UTC (6 years, 1 month ago) by vapier
File MIME type: text/x-csrc
File size: 758 byte(s)
consolidate all random system includes into headers.h
1 /*
2 * sb_open.c
3 *
4 * IO functions.
5 *
6 * Copyright 1999-2008 Gentoo Foundation
7 * Licensed under the GPL-2
8 */
9
10 #include "headers.h"
11 #include "sbutil.h"
12
13 static int (*sbio_open)(const char *, int, mode_t) = (void *)open;
14
15
16 void sb_set_open(void *new_open)
17 {
18 if (!check_ptr(new_open))
19 return;
20
21 sbio_open = new_open;
22 }
23
24 /* General purpose function to _reliably_ open a file
25 *
26 * Returns the file descriptor or -1 on error (and errno set)
27 */
28
29 int sb_open(const char *path, int flags, mode_t mode)
30 {
31 int fd;
32
33 do {
34 fd = sbio_open(path, flags, mode);
35 } while ((-1 == fd) && (EINTR == errno));
36
37 if ((-1 != fd) && (0 != errno))
38 /* Do not trigger debugging */
39 errno = 0;
40
41 if (-1 == fd)
42 DBG_MSG("Failed to open file '%s'!\n", path);
43
44 return fd;
45 }

  ViewVC Help
Powered by ViewVC 1.1.20