Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
7fa90630
Unverified
Commit
7fa90630
authored
Mar 10, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file_utils: handle libcs without fmemopen()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
77c3e9a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
configure.ac
configure.ac
+4
-0
file_utils.c
src/lxc/file_utils.c
+22
-1
No files found.
configure.ac
View file @
7fa90630
...
...
@@ -701,6 +701,10 @@ AC_CHECK_FUNCS([strlcat],
AM_CONDITIONAL(HAVE_STRLCAT, true)
AC_DEFINE(HAVE_STRLCAT,1,[Have strlcat]),
AM_CONDITIONAL(HAVE_STRLCAT, false))
AC_CHECK_FUNCS([fmemopen],
AM_CONDITIONAL(HAVE_FMEMOPEN, true)
AC_DEFINE(HAVE_FMEMOPEN,1,[Have fmemopen]),
AM_CONDITIONAL(HAVE_FMEMOPEN, false))
# HAVE_STRUCT_RTNL_LINK_STATS64={0,1}
AC_CHECK_TYPES([struct rtnl_link_stats64], [], [], [[#include <linux/if_link.h>]])
...
...
src/lxc/file_utils.c
View file @
7fa90630
...
...
@@ -470,6 +470,7 @@ char *file_to_buf(const char *path, size_t *length)
FILE
*
fopen_cached
(
const
char
*
path
,
const
char
*
mode
,
void
**
caller_freed_buffer
)
{
#ifdef HAVE_FMEMOPEN
__do_free
char
*
buf
=
NULL
;
size_t
len
=
0
;
FILE
*
f
;
...
...
@@ -483,13 +484,17 @@ FILE *fopen_cached(const char *path, const char *mode, void **caller_freed_buffe
return
NULL
;
*
caller_freed_buffer
=
move_ptr
(
buf
);
return
f
;
#else
return
fopen
(
path
,
mode
);
#endif
}
FILE
*
fdopen_cached
(
int
fd
,
const
char
*
mode
,
void
**
caller_freed_buffer
)
{
FILE
*
f
;
#ifdef HAVE_FMEMOPEN
__do_free
char
*
buf
=
NULL
;
size_t
len
=
0
;
FILE
*
f
;
buf
=
fd_to_buf
(
fd
,
&
len
);
if
(
!
buf
)
...
...
@@ -500,5 +505,21 @@ FILE *fdopen_cached(int fd, const char *mode, void **caller_freed_buffer)
return
NULL
;
*
caller_freed_buffer
=
move_ptr
(
buf
);
#else
__do_close_prot_errno
int
dupfd
=
-
EBADF
;
dupfd
=
dup
(
fd
);
if
(
dupfd
<
0
)
return
NULL
;
f
=
fdopen
(
dupfd
,
"re"
);
if
(
!
f
)
return
NULL
;
/* Transfer ownership of fd. */
move_fd
(
dupfd
);
#endif
return
f
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment