int SMTPFileSystem::utime(const char *path, struct utimbuf *ubuf) { std::string tmp_basename(smtpfs_basename(std::string(path))); std::string tmp_dirname(smtpfs_dirname(std::string(path))); const TypeDir *parent = m_device.dirFetchContent(tmp_dirname); if (!parent) return -ENOENT; const TypeFile *file = parent->file(tmp_basename); if (!file) return -ENOENT; const_cast<TypeFile*>(file)->setModificationDate(ubuf->modtime); return 0; }
int SMTPFileSystem::getattr(const char *path, struct stat *buf) { memset(buf, 0, sizeof(struct stat)); struct fuse_context *fc = fuse_get_context(); buf->st_uid = fc->uid; buf->st_gid = fc->gid; if (path == std::string("/")) { buf->st_mode = S_IFDIR | 0775; buf->st_nlink = 2; return 0; } else { std::string tmp_path(smtpfs_dirname(path)); std::string tmp_file(smtpfs_basename(path)); const TypeDir *content = m_device.dirFetchContent(tmp_path); if (!content) { return -ENOENT; } if (content->dir(tmp_file)) { const TypeDir *dir = content->dir(tmp_file); buf->st_ino = dir->id(); buf->st_mode = S_IFDIR | 0775; buf->st_nlink = 2; buf->st_mtime = dir->modificationDate(); } else if (content->file(tmp_file)) { const TypeFile *file = content->file(tmp_file); buf->st_ino = file->id(); buf->st_size = file->size(); buf->st_blocks = (file->size() / 512) + (file->size() % 512 > 0 ? 1 : 0); buf->st_nlink = 1; buf->st_mode = S_IFREG | 0644; buf->st_mtime = file->modificationDate(); buf->st_ctime = buf->st_mtime; buf->st_atime = buf->st_mtime; } else { return -ENOENT; } } return 0; }