Lines Matching refs:fs
14 #include "fs-api-private.h"
32 struct fs fs;
67 static struct fs *fs_posix_alloc(void)
69 struct posix_fs *fs;
71 fs = i_new(struct posix_fs, 1);
72 fs->fs = fs_class_posix;
73 return &fs->fs;
77 fs_posix_init(struct fs *_fs, const char *args, const struct fs_settings *set)
79 struct posix_fs *fs = (struct posix_fs *)_fs;
82 fs->temp_file_prefix = set->temp_file_prefix != NULL ?
84 fs->temp_file_prefix_len = strlen(fs->temp_file_prefix);
85 fs->root_path = i_strdup(set->root_path);
86 fs->fs.set.temp_file_prefix = fs->temp_file_prefix;
87 fs->fs.set.root_path = fs->root_path;
89 fs->lock_method = FS_POSIX_LOCK_METHOD_FLOCK;
90 fs->mode = FS_DEFAULT_MODE;
97 fs->lock_method = FS_POSIX_LOCK_METHOD_FLOCK;
99 fs->lock_method = FS_POSIX_LOCK_METHOD_DOTLOCK;
101 i_free(fs->path_prefix);
102 fs->path_prefix = i_strdup(arg + 7);
104 fs->mode_auto = TRUE;
106 fs->have_dirs = TRUE;
108 fs->disable_fsync = TRUE;
115 fs->mode = mode & 0666;
116 if (fs->mode == 0) {
128 static void fs_posix_deinit(struct fs *_fs)
130 struct posix_fs *fs = (struct posix_fs *)_fs;
132 i_free(fs->temp_file_prefix);
133 i_free(fs->root_path);
134 i_free(fs->path_prefix);
135 i_free(fs);
138 static enum fs_properties fs_posix_get_properties(struct fs *_fs)
140 struct posix_fs *fs = (struct posix_fs *)_fs;
149 able to use doveadm fs commands to delete empty directories. */
150 if (fs->have_dirs)
156 fs_posix_get_mode(struct posix_fs *fs, const char *path, mode_t *mode_r)
161 *mode_r = fs->mode;
165 fs_set_error(&fs->fs, "stat(%s) failed: %m", path);
183 static int fs_posix_mkdir_parents(struct posix_fs *fs, const char *path)
193 if (fs_posix_get_mode(fs, dir, &mode) < 0)
205 fs_set_error(&fs->fs, "mkdir_parents(%s) failed: %m", dir);
210 static int fs_posix_rmdir_parents(struct posix_fs *fs, const char *path)
214 if (fs->have_dirs)
216 if (fs->root_path == NULL && fs->path_prefix == NULL)
221 if ((fs->root_path != NULL && strcmp(path, fs->root_path) == 0) ||
222 (fs->path_prefix != NULL && strncmp(path, fs->path_prefix, strlen(path)) == 0))
233 fs_set_error(&fs->fs, "rmdir(%s) failed: %m", path);
242 struct posix_fs *fs = (struct posix_fs *)file->file.fs;
253 if (fs_posix_get_mode(fs, str_c(str), &mode) < 0)
257 if (fs_posix_get_mode(fs, ".", &mode) < 0)
260 str_append(str, fs->temp_file_prefix);
265 if (fs_posix_mkdir_parents(fs, str_c(str)) < 0)
271 fs_set_error(&fs->fs, "safe_mkstemp(%s) failed: %m", str_c(str));
280 struct posix_fs *fs = (struct posix_fs *)file->file.fs;
289 fs_set_error(&fs->fs, "open(%s) failed: %m", path);
294 fs_set_error(&fs->fs, "open(%s) failed: %m", path);
320 struct posix_fs *fs = (struct posix_fs *)_file->fs;
330 file->full_path = fs->path_prefix == NULL ? i_strdup(file->file.path) :
331 i_strconcat(fs->path_prefix, file->file.path, NULL);
343 fs_set_critical(file->file.fs, "close(%s) failed: %m",
367 fs_set_critical(_file->fs, "unlink(%s) failed: %m",
419 fs_set_critical(_file->fs, "lseek(%s, 0) failed: %m",
427 fs_set_error(_file->fs, "read(%s) failed: %m", file->full_path);
439 input = i_stream_create_error_str(errno, "%s", fs_last_error(_file->fs));
450 struct posix_fs *fs = (struct posix_fs *)file->file.fs;
466 file->full_path = fs->path_prefix == NULL ? i_strdup(file->file.path) :
467 i_strconcat(fs->path_prefix, file->file.path, NULL);
472 struct posix_fs *fs = (struct posix_fs *)file->file.fs;
476 !fs->disable_fsync) {
478 fs_set_error(file->file.fs, "fdatasync(%s) failed: %m",
489 fs_set_error(file->file.fs, "link(%s, %s) failed: %m",
494 fs_set_error(file->file.fs, "unlink(%s) failed: %m",
506 fs_set_error(file->file.fs, "rename(%s, %s) failed: %m",
534 fs_set_error(_file->fs, "write(%s) failed: %m",
544 fs_set_error(_file->fs, "write(%s) failed: %m", file->full_path);
548 fs_set_error(_file->fs,
608 struct posix_fs *fs = (struct posix_fs *)_file->fs;
616 switch (fs->lock_method) {
619 fs_set_error(_file->fs, "flock() not supported by OS "
632 fs_set_error(_file->fs, "flock(%s) failed: %m",
648 fs_set_error(_file->fs,
681 fs_set_error(_file->fs, "stat(%s) failed: %m",
696 fs-sis after fs_copy(). */
699 fs_set_error(_file->fs, "fstat(%s) failed: %m", file->full_path);
704 fs_set_error(_file->fs, "stat(%s) failed: %m", file->full_path);
715 struct posix_fs *fs = (struct posix_fs *)_src->fs;
727 if (fs_posix_mkdir_parents(fs, dest->full_path) < 0)
733 fs_set_error(_src->fs, "link(%s, %s) failed: %m",
742 struct posix_fs *fs = (struct posix_fs *)_src->fs;
751 if (fs_posix_mkdir_parents(fs, dest->full_path) < 0)
757 fs_set_error(_src->fs, "rename(%s, %s) failed: %m",
767 struct posix_fs *fs = (struct posix_fs *)_file->fs;
771 fs_set_error(_file->fs, "unlink(%s) failed: %m", file->full_path);
777 fs_set_error(_file->fs, "rmdir(%s) failed: %m", file->full_path);
781 (void)fs_posix_rmdir_parents(fs, file->full_path);
796 struct posix_fs *fs = (struct posix_fs *)_iter->fs;
798 iter->path = fs->path_prefix == NULL ? i_strdup(path) :
799 i_strconcat(fs->path_prefix, path, NULL);
807 fs_set_error(_iter->fs, "opendir(%s) failed: %m", iter->path);
832 struct posix_fs *fs = (struct posix_fs *)_iter->fs;
843 if (strncmp(d->d_name, fs->temp_file_prefix,
844 fs->temp_file_prefix_len) == 0)
871 fs_set_error(_iter->fs, "readdir(%s) failed: %m", iter->path);
883 fs_set_error(_iter->fs, "closedir(%s) failed: %m", iter->path);
894 const struct fs fs_class_posix = {