From: Timo Sirainen Date: Fri, 29 Nov 2019 13:56:22 +0000 (+0200) Subject: fs-sis: Change some internal functions to take fs_file instead of fs X-Git-Tag: 2.3.10~213 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d8bdd8b650c3bbd3aae10f40aeb69ebe7d3dd488;p=thirdparty%2Fdovecot%2Fcore.git fs-sis: Change some internal functions to take fs_file instead of fs --- diff --git a/src/lib-fs/fs-sis-common.c b/src/lib-fs/fs-sis-common.c index 8a916b9583..ea607aba9b 100644 --- a/src/lib-fs/fs-sis-common.c +++ b/src/lib-fs/fs-sis-common.c @@ -5,7 +5,7 @@ #include -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 "-" */ 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 '-'", 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. */ diff --git a/src/lib-fs/fs-sis-common.h b/src/lib-fs/fs-sis-common.h index c7f25b4d24..5156ca6c96 100644 --- a/src/lib-fs/fs-sis-common.h +++ b/src/lib-fs/fs-sis-common.h @@ -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 diff --git a/src/lib-fs/fs-sis-queue.c b/src/lib-fs/fs-sis-queue.c index 86d92211c0..7833cea991 100644 --- a/src/lib-fs/fs-sis-queue.c +++ b/src/lib-fs/fs-sis-queue.c @@ -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); } diff --git a/src/lib-fs/fs-sis.c b/src/lib-fs/fs-sis.c index 749d65a6bf..6a72e3df53 100644 --- a/src/lib-fs/fs-sis.c +++ b/src/lib-fs/fs-sis.c @@ -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); }