]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fs-sis: Change some internal functions to take fs_file instead of fs
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 29 Nov 2019 13:56:22 +0000 (15:56 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 11 Dec 2019 10:12:30 +0000 (10:12 +0000)
src/lib-fs/fs-sis-common.c
src/lib-fs/fs-sis-common.h
src/lib-fs/fs-sis-queue.c
src/lib-fs/fs-sis.c

index 8a916b9583665a05b76a400de044b25b865eb782..ea607aba9bdc791188808239c2f7be8a209fb9a9 100644 (file)
@@ -5,7 +5,7 @@
 
 #include <sys/stat.h>
 
-int fs_sis_path_parse(struct fs *fs, const char *path,
+int fs_sis_path_parse(struct fs_file *file, const char *path,
                      const char **dir_r, const char **hash_r)
 {
        const char *fname, *p;
@@ -22,7 +22,7 @@ int fs_sis_path_parse(struct fs *fs, const char *path,
        /* assume filename begins with "<hash>-" */
        p = strchr(fname, '-');
        if (p == NULL) {
-               fs_set_error(fs, "open(%s) failed: "
+               fs_set_error(file->fs, "open(%s) failed: "
                             "Filenames must begin with '<hash>-'", path);
                return -1;
        }
@@ -30,13 +30,14 @@ int fs_sis_path_parse(struct fs *fs, const char *path,
        return 0;
 }
 
-void fs_sis_try_unlink_hash_file(struct fs *sis_fs, struct fs_file *super_file)
+void fs_sis_try_unlink_hash_file(struct fs_file *sis_file,
+                                struct fs_file *super_file)
 {
        struct fs_file *hash_file;
        struct stat st1, st2;
        const char *dir, *hash, *hash_path;
 
-       if (fs_sis_path_parse(sis_fs, super_file->path, &dir, &hash) == 0 &&
+       if (fs_sis_path_parse(sis_file, super_file->path, &dir, &hash) == 0 &&
            fs_stat(super_file, &st1) == 0 && st1.st_nlink == 2) {
                /* this may be the last link. if hashes/ file is the same,
                   delete it. */
index c7f25b4d2475f751d8143ad7c36feb9631f763e3..5156ca6c96262c42a1aa343da808c2ed3d1ec202 100644 (file)
@@ -5,9 +5,10 @@
 
 #define HASH_DIR_NAME "hashes"
 
-int fs_sis_path_parse(struct fs *fs, const char *path,
+int fs_sis_path_parse(struct fs_file *file, const char *path,
                      const char **dir_r, const char **hash_r);
-void fs_sis_try_unlink_hash_file(struct fs *sis_fs, struct fs_file *super_file);
+void fs_sis_try_unlink_hash_file(struct fs_file *sis_file,
+                                struct fs_file *super_file);
 
 #endif
 
index 86d92211c0016913e6df36e643e4c41ad0b17b4d..7833cea9913af6c912fb9b65e5362aa612d77031 100644 (file)
@@ -163,7 +163,7 @@ static int fs_sis_queue_write_stream_finish(struct fs_file *_file, bool success)
 static int fs_sis_queue_delete(struct fs_file *_file)
 {
        T_BEGIN {
-               fs_sis_try_unlink_hash_file(_file->fs, _file->parent);
+               fs_sis_try_unlink_hash_file(_file, _file->parent);
        } T_END;
        return fs_delete(_file->parent);
 }
index 749d65a6bf677b79053526a01459a5c1a1dfd1e2..6a72e3df533839c388fa041522a8bcb157258de6 100644 (file)
@@ -97,7 +97,7 @@ fs_sis_file_init(struct fs_file *_file, const char *path,
                return;
        }
 
-       if (fs_sis_path_parse(_file->fs, path, &dir, &hash) < 0) {
+       if (fs_sis_path_parse(_file, path, &dir, &hash) < 0) {
                fs_set_error(_file->fs, "Invalid path");
                return;
        }
@@ -324,7 +324,7 @@ static int fs_sis_write_stream_finish(struct fs_file *_file, bool success)
 static int fs_sis_delete(struct fs_file *_file)
 {
        T_BEGIN {
-               fs_sis_try_unlink_hash_file(_file->fs, _file->parent);
+               fs_sis_try_unlink_hash_file(_file, _file->parent);
        } T_END;
        return fs_delete(_file->parent);
 }