summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2022-05-19 17:37:46 +0200
committerJaroslav Kysela <perex@perex.cz>2022-05-20 09:55:03 +0200
commitedec439a0ce5f81bfc9fdf1ec3d261ebcc1df95a (patch)
tree19cbf7f08773ae0f2d4748ce070d3451e352e187
parent45b65fa4c1f647159e453ffc3abe0218621e22c2 (diff)
downloadalsa-lib-edec439a0ce5f81bfc9fdf1ec3d261ebcc1df95a.tar.gz
ucm: Use LFS calls (stat, scandir)
Continue the work in commit ba86ac55 ("conf: Use LFS calls when reading config files") and fix the UCM code, too. Fixes: https://github.com/alsa-project/alsa-lib/pull/223 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--src/ucm/main.c8
-rw-r--r--src/ucm/parser.c16
-rw-r--r--src/ucm/ucm_exec.c10
-rw-r--r--src/ucm/ucm_subs.c4
4 files changed, 19 insertions, 19 deletions
diff --git a/src/ucm/main.c b/src/ucm/main.c
index 65cdeaa8..730872c2 100644
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -166,7 +166,7 @@ static int read_tlv_file(unsigned int **res,
{
int err = 0;
int fd;
- struct stat st;
+ struct stat64 st;
size_t sz;
ssize_t sz_read;
struct snd_ctl_tlv *tlv;
@@ -176,7 +176,7 @@ static int read_tlv_file(unsigned int **res,
err = -errno;
return err;
}
- if (fstat(fd, &st) == -1) {
+ if (fstat64(fd, &st) == -1) {
err = -errno;
goto __fail;
}
@@ -218,7 +218,7 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst,
{
int err = 0;
int fd;
- struct stat st;
+ struct stat64 st;
size_t sz;
ssize_t sz_read;
char *res;
@@ -236,7 +236,7 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst,
err = -errno;
return err;
}
- if (stat(filepath, &st) == -1) {
+ if (stat64(filepath, &st) == -1) {
err = -errno;
goto __fail;
}
diff --git a/src/ucm/parser.c b/src/ucm/parser.c
index b5ee62a7..4bbd13e8 100644
--- a/src/ucm/parser.c
+++ b/src/ucm/parser.c
@@ -36,7 +36,7 @@
#include <dirent.h>
#include <limits.h>
-static int filename_filter(const struct dirent *dirent);
+static int filename_filter(const struct dirent64 *dirent);
static int parse_sequence(snd_use_case_mgr_t *uc_mgr,
struct list_head *base,
@@ -2549,7 +2549,7 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr,
snd_config_t *n, *n2;
const char *id;
char *dir = NULL, *file = NULL, fn[PATH_MAX];
- struct stat st;
+ struct stat64 st;
long version;
int err;
@@ -2624,7 +2624,7 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr,
}
ucm_filename(fn, sizeof(fn), version, dir, file);
- if (access(fn, R_OK) == 0 && lstat(fn, &st) == 0) {
+ if (access(fn, R_OK) == 0 && lstat64(fn, &st) == 0) {
if (st.st_mode & S_IFLNK) {
ssize_t r;
char *link, *dir2, *p;
@@ -2838,7 +2838,7 @@ __error:
return err;
}
-static int filename_filter(const struct dirent *dirent)
+static int filename_filter(const struct dirent64 *dirent)
{
if (dirent == NULL)
return 0;
@@ -2872,7 +2872,7 @@ int uc_mgr_scan_master_configs(const char **_list[])
int i, j, cnt, err;
long l;
ssize_t ss;
- struct dirent **namelist;
+ struct dirent64 **namelist;
if (env)
snprintf(filename, sizeof(filename), "%s/conf.virt.d", env);
@@ -2881,11 +2881,11 @@ int uc_mgr_scan_master_configs(const char **_list[])
snd_config_topdir());
#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__sun) && !defined(ANDROID)
-#define SORTFUNC versionsort
+#define SORTFUNC versionsort64
#else
-#define SORTFUNC alphasort
+#define SORTFUNC alphasort64
#endif
- err = scandir(filename, &namelist, filename_filter, SORTFUNC);
+ err = scandir64(filename, &namelist, filename_filter, SORTFUNC);
if (err < 0) {
err = -errno;
uc_error("error: could not scan directory %s: %s",
diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c
index 4ddf5d15..fffff55c 100644
--- a/src/ucm/ucm_exec.c
+++ b/src/ucm/ucm_exec.c
@@ -44,10 +44,10 @@ static int find_exec(const char *name, char *out, size_t len)
char bin[PATH_MAX];
char *path, *tmp, *tmp2 = NULL;
DIR *dir;
- struct dirent *de;
- struct stat st;
+ struct dirent64 *de;
+ struct stat64 st;
if (name[0] == '/') {
- if (lstat(name, &st))
+ if (lstat64(name, &st))
return 0;
if (!S_ISREG(st.st_mode) || !(st.st_mode & S_IEXEC))
return 0;
@@ -63,12 +63,12 @@ static int find_exec(const char *name, char *out, size_t len)
tmp = strtok_r(path, ":", &tmp2);
while (tmp && !ret) {
if ((dir = opendir(tmp))) {
- while ((de = readdir(dir))) {
+ while ((de = readdir64(dir))) {
if (strstr(de->d_name, name) != de->d_name)
continue;
snprintf(bin, sizeof(bin), "%s/%s", tmp,
de->d_name);
- if (lstat(bin, &st))
+ if (lstat64(bin, &st))
continue;
if (!S_ISREG(st.st_mode)
|| !(st.st_mode & S_IEXEC))
diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c
index 6ff21853..2261bdc2 100644
--- a/src/ucm/ucm_subs.c
+++ b/src/ucm/ucm_subs.c
@@ -499,7 +499,7 @@ static char *rval_env(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char *i
static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char *id)
{
char path[PATH_MAX], link[PATH_MAX + 1];
- struct stat sb;
+ struct stat64 sb;
ssize_t len;
const char *e;
int fd;
@@ -510,7 +510,7 @@ static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char
if (id[0] == '/')
id++;
snprintf(path, sizeof(path), "%s/%s", e, id);
- if (lstat(path, &sb) != 0)
+ if (lstat64(path, &sb) != 0)
return NULL;
if (S_ISLNK(sb.st_mode)) {
len = readlink(path, link, sizeof(link) - 1);