mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
v4l2: follow symlinks
This commit is contained in:
parent
f62c40c205
commit
5c96928d12
1 changed files with 13 additions and 1 deletions
|
|
@ -28,6 +28,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
@ -786,13 +787,17 @@ static int v4l2_dup(int oldfd)
|
||||||
return do_dup(oldfd, FD_MAP_DUP);
|
return do_dup(oldfd, FD_MAP_DUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int v4l2_openat(int dirfd, const char *path, int oflag, mode_t mode)
|
static int v4l2_openat(int dirfd, const char *requested_path, int oflag, mode_t mode)
|
||||||
{
|
{
|
||||||
int res, flags;
|
int res, flags;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
bool passthrough = true;
|
bool passthrough = true;
|
||||||
uint32_t dev_id = SPA_ID_INVALID;
|
uint32_t dev_id = SPA_ID_INVALID;
|
||||||
|
|
||||||
|
char *path = realpath(requested_path, NULL);
|
||||||
|
if (path <= 0)
|
||||||
|
path = (char *)requested_path;
|
||||||
|
|
||||||
if (spa_strstartswith(path, "/dev/video")) {
|
if (spa_strstartswith(path, "/dev/video")) {
|
||||||
if (spa_atou32(path+10, &dev_id, 10) && dev_id < MAX_DEV)
|
if (spa_atou32(path+10, &dev_id, 10) && dev_id < MAX_DEV)
|
||||||
passthrough = false;
|
passthrough = false;
|
||||||
|
|
@ -876,6 +881,9 @@ static int v4l2_openat(int dirfd, const char *path, int oflag, mode_t mode)
|
||||||
add_dev_for_serial(file->dev_id, file->serial);
|
add_dev_for_serial(file->dev_id, file->serial);
|
||||||
unref_file(file);
|
unref_file(file);
|
||||||
|
|
||||||
|
if (path > 0 && path != requested_path)
|
||||||
|
free(path);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
error_unlock:
|
error_unlock:
|
||||||
|
|
@ -888,6 +896,10 @@ error:
|
||||||
pw_log_info("path:%s oflag:%d mode:%d -> %d (%s)", path, oflag, mode,
|
pw_log_info("path:%s oflag:%d mode:%d -> %d (%s)", path, oflag, mode,
|
||||||
-1, spa_strerror(res));
|
-1, spa_strerror(res));
|
||||||
errno = -res;
|
errno = -res;
|
||||||
|
|
||||||
|
if (path > 0 && path != requested_path)
|
||||||
|
free(path);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue