Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
ab29a459
Commit
ab29a459
authored
Aug 24, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filesystem: add vlc_memfd() helper
parent
cc8bb2ed
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
1 deletion
+70
-1
configure.ac
configure.ac
+1
-1
include/vlc_fs.h
include/vlc_fs.h
+13
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/os2/filesystem.c
src/os2/filesystem.c
+6
-0
src/posix/filesystem.c
src/posix/filesystem.c
+29
-0
src/win32/filesystem.c
src/win32/filesystem.c
+20
-0
No files found.
configure.ac
View file @
ab29a459
...
@@ -536,7 +536,7 @@ need_libc=false
...
@@ -536,7 +536,7 @@ need_libc=false
dnl Check for usual libc functions
dnl Check for usual libc functions
AC_CHECK_DECLS([nanosleep],,,[#include <time.h>])
AC_CHECK_DECLS([nanosleep],,,[#include <time.h>])
AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r isatty lstat memalign mmap open_memstream openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale pthread_cond_timedwait_monotonic_np pthread_condattr_setclock])
AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r isatty lstat memalign m
kostemp m
map open_memstream openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale pthread_cond_timedwait_monotonic_np pthread_condattr_setclock])
AC_REPLACE_FUNCS([atof atoll dirfd fdopendir ffsll flockfile fsync getdelim getpid lldiv nrand48 poll posix_memalign rewind setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
AC_REPLACE_FUNCS([atof atoll dirfd fdopendir ffsll flockfile fsync getdelim getpid lldiv nrand48 poll posix_memalign rewind setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
AC_CHECK_FUNCS(fdatasync,,
AC_CHECK_FUNCS(fdatasync,,
[AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
[AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.])
...
...
include/vlc_fs.h
View file @
ab29a459
...
@@ -93,6 +93,19 @@ VLC_API int vlc_dup(int) VLC_USED;
...
@@ -93,6 +93,19 @@ VLC_API int vlc_dup(int) VLC_USED;
*/
*/
VLC_API
int
vlc_pipe
(
int
[
2
])
VLC_USED
;
VLC_API
int
vlc_pipe
(
int
[
2
])
VLC_USED
;
/**
* Creates an anonymous regular file descriptor, i.e. a descriptor for a
* temporary file.
*
* The file is initially empty. The storage space is automatically reclaimed
* when all file descriptors referencing it are closed.
*
* The new file descriptor has the close-on-exec flag preset.
*
* @return a file descriptor on success, -1 on error (see errno)
*/
VLC_API
int
vlc_memfd
(
void
)
VLC_USED
;
/**
/**
* Writes data to a file descriptor. Unlike write(), if EPIPE error occurs,
* Writes data to a file descriptor. Unlike write(), if EPIPE error occurs,
* this function does not generate a SIGPIPE signal.
* this function does not generate a SIGPIPE signal.
...
...
src/libvlccore.sym
View file @
ab29a459
...
@@ -450,6 +450,7 @@ vlc_mkdir
...
@@ -450,6 +450,7 @@ vlc_mkdir
vlc_mkstemp
vlc_mkstemp
vlc_open
vlc_open
vlc_openat
vlc_openat
vlc_memfd
vlc_opendir
vlc_opendir
vlc_readdir
vlc_readdir
vlc_scandir
vlc_scandir
...
...
src/os2/filesystem.c
View file @
ab29a459
...
@@ -79,6 +79,12 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
...
@@ -79,6 +79,12 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
return
-
1
;
return
-
1
;
}
}
int
vlc_memfd
(
void
)
{
errno
=
ENOSYS
;
return
-
1
;
}
int
vlc_mkdir
(
const
char
*
dirname
,
mode_t
mode
)
int
vlc_mkdir
(
const
char
*
dirname
,
mode_t
mode
)
{
{
char
*
locname
=
ToLocaleDup
(
dirname
);
char
*
locname
=
ToLocaleDup
(
dirname
);
...
...
src/posix/filesystem.c
View file @
ab29a459
...
@@ -98,6 +98,35 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
...
@@ -98,6 +98,35 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
return
fd
;
return
fd
;
}
}
int
vlc_memfd
(
void
)
{
int
fd
;
#ifdef O_TMPFILE
fd
=
vlc_open
(
"/tmp"
,
O_RDWR
|
O_TMPFILE
,
S_IRUSR
|
S_IWUSR
);
if
(
fd
!=
-
1
)
return
fd
;
/* ENOENT means either /tmp is missing (!) or the kernel does not support
* O_TMPFILE. EISDIR means /tmp exists but the kernel does not support
* O_TMPFILE. EOPNOTSUPP means the kernel supports O_TMPFILE but the /tmp
* filesystem does not. Do not fallback on other errors. */
if
(
errno
!=
ENOENT
&&
errno
!=
EISDIR
&&
errno
!=
EOPNOTSUPP
)
return
-
1
;
#endif
char
bufpath
[]
=
"/tmp/"
PACKAGE_NAME
"XXXXXX"
;
#ifdef HAVE_MKOSTEMP
fd
=
mkostemp
(
bufpath
,
O_CLOEXEC
);
#else
fd
=
mkstemp
(
bufpath
);
#endif
if
(
fd
!=
-
1
)
{
fcntl
(
fd
,
F_SETFD
,
FD_CLOEXEC
);
unlink
(
bufpath
);
}
return
fd
;
}
int
vlc_mkdir
(
const
char
*
dirname
,
mode_t
mode
)
int
vlc_mkdir
(
const
char
*
dirname
,
mode_t
mode
)
{
{
...
...
src/win32/filesystem.c
View file @
ab29a459
...
@@ -104,6 +104,26 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
...
@@ -104,6 +104,26 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
return
-
1
;
return
-
1
;
}
}
int
vlc_memfd
(
void
)
{
#if 0
int fd, err;
FILE *stream = tmpfile();
if (stream == NULL)
return -1;
fd = vlc_dup(fileno(stream));
err = errno;
fclose(stream);
errno = err;
return fd;
#else
/* Not currently used */
errno
=
ENOSYS
;
return
-
1
;
#endif
}
int
vlc_mkdir
(
const
char
*
dirname
,
mode_t
mode
)
int
vlc_mkdir
(
const
char
*
dirname
,
mode_t
mode
)
{
{
wchar_t
*
wpath
=
widen_path
(
dirname
);
wchar_t
*
wpath
=
widen_path
(
dirname
);
...
...
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