1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/libfsserver/include/fsserver/ext2_directory.h Fri Sep 10 23:57:02 2021 +0200
1.3 @@ -0,0 +1,76 @@
1.4 +/*
1.5 + * An object for a directory provided by an Ext2-compatible filesystem.
1.6 + *
1.7 + * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License as
1.11 + * published by the Free Software Foundation; either version 2 of
1.12 + * the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 + * Boston, MA 02110-1301, USA
1.23 + */
1.24 +
1.25 +#pragma once
1.26 +
1.27 +#include <ext2fs/ext2fs.h>
1.28 +
1.29 +#include <fsclient/file.h>
1.30 +#include <fsserver/ext2_file_operations.h>
1.31 +#include <fsserver/directory_resource.h>
1.32 +
1.33 +
1.34 +
1.35 +/* Forward declarations. */
1.36 +
1.37 +struct Ext2DirectoryState;
1.38 +
1.39 +
1.40 +
1.41 +/* Support for providing access to files. */
1.42 +
1.43 +class Ext2Directory : public DirectoryResource
1.44 +{
1.45 +protected:
1.46 + Ext2FileOperations *_ops;
1.47 + fileid_t _fileid;
1.48 +
1.49 + virtual long _opendir(flags_t flags, offset_t *size, l4_cap_idx_t *cap,
1.50 + object_flags_t *object_flags);
1.51 +
1.52 +public:
1.53 + explicit Ext2Directory(Ext2FileOperations *ops, fileid_t fileid)
1.54 + : _ops(ops), _fileid(fileid)
1.55 + {
1.56 + }
1.57 +
1.58 + virtual ~Ext2Directory();
1.59 +
1.60 + /* Helper methods. */
1.61 +
1.62 + void read_directory(fileid_t fileid, file_t *writer);
1.63 +
1.64 + int write_directory_entry(struct Ext2DirectoryState *dir);
1.65 +};
1.66 +
1.67 +
1.68 +
1.69 +/* Helper structures. */
1.70 +
1.71 +struct Ext2DirectoryState
1.72 +{
1.73 + Ext2Directory *directory;
1.74 + file_t *writer;
1.75 + struct ext2_dir_entry *entry;
1.76 + long offset;
1.77 +};
1.78 +
1.79 +// vim: tabstop=4 expandtab shiftwidth=4