]> git.alsa-project.org Git - alsa-lib.git/commitdiff
conf: Use LFS calls when reading config files
authorSebastian Krzyszkowiak <dos@dosowisko.net>
Thu, 28 Apr 2022 20:46:56 +0000 (22:46 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 20 May 2022 07:54:32 +0000 (09:54 +0200)
Although at first glance it doesn't seem useful to support config
files larger than 2GB, LFS also influences inode size. Without this,
32-bit libasound may be unable to read config files on filesystems
with 64-bit inodes, such as Btrfs or NFS.

Fixes: https://github.com/alsa-project/alsa-lib/pull/223
Signed-off-by: Sebastian Krzyszkowiak <dos@dosowisko.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/conf.c

index e7f9e78c2fb31b85387f0f8384313fdbdf203634..3d2b4a5bc1841a0b0b9d10984e4d3ab6f23e2019 100644 (file)
@@ -4064,7 +4064,7 @@ static int snd_config_hooks(snd_config_t *config, snd_config_t *private_data)
        return err;
 }
 
-static int config_filename_filter(const struct dirent *dirent)
+static int config_filename_filter(const struct dirent64 *dirent)
 {
        size_t flen;
 
@@ -4102,13 +4102,13 @@ static int config_file_open(snd_config_t *root, const char *filename)
 
 static int config_file_load(snd_config_t *root, const char *fn, int errors)
 {
-       struct stat st;
-       struct dirent **namelist;
+       struct stat64 st;
+       struct dirent64 **namelist;
        int err, n;
 
        if (!errors && access(fn, R_OK) < 0)
                return 1;
-       if (stat(fn, &st) < 0) {
+       if (stat64(fn, &st) < 0) {
                SNDERR("cannot stat file/directory %s", fn);
                return 1;
        }
@@ -4116,12 +4116,12 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors)
                return config_file_open(root, fn);
 #ifndef DOC_HIDDEN
 #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
 #endif
-       n = scandir(fn, &namelist, config_filename_filter, SORTFUNC);
+       n = scandir64(fn, &namelist, config_filename_filter, SORTFUNC);
        if (n > 0) {
                int j;
                err = 0;
@@ -4545,9 +4545,9 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons
                c++;
        }
        for (k = 0; k < local->count; ++k) {
-               struct stat st;
+               struct stat64 st;
                struct finfo *lf = &local->finfo[k];
-               if (stat(lf->name, &st) >= 0) {
+               if (stat64(lf->name, &st) >= 0) {
                        lf->dev = st.st_dev;
                        lf->ino = st.st_ino;
                        lf->mtime = st.st_mtime;