]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: Use LFS calls (stat, scandir)
authorJaroslav Kysela <perex@perex.cz>
Thu, 19 May 2022 15:37:46 +0000 (17:37 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 20 May 2022 07:55:03 +0000 (09:55 +0200)
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>
src/ucm/main.c
src/ucm/parser.c
src/ucm/ucm_exec.c
src/ucm/ucm_subs.c

index 65cdeaa88a197ab2b74637d47cbf317118dc5171..730872c2187438e2d3368fa07dbae2a7fa4c06ca 100644 (file)
@@ -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;
        }
index b5ee62a7525a4ac84117202755924d9db8d20626..4bbd13e8700049a21319f4254d50a82a39c521b7 100644 (file)
@@ -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",
index 4ddf5d1574e9473a0e0e188c9a5b9f6bde0877bf..fffff55c2cc4af855a6373bc0ae9aefe414c9a1d 100644 (file)
@@ -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))
index 6ff21853360f400219d7eb5ba572e05a78c7bb56..2261bdc20f3d2ba9e0ae65dbd200458ca3b03752 100644 (file)
@@ -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);