1.1 --- a/include/fs_accessor.h Sat Sep 14 01:26:59 2019 +0200
1.2 +++ b/include/fs_accessor.h Mon Oct 07 15:24:20 2019 +0200
1.3 @@ -38,6 +38,7 @@
1.4 private:
1.5 ext2_filsys _fs;
1.6 ext2_ino_t _ino_file;
1.7 + int _flags;
1.8
1.9 /* Interaction with the file from the block device. */
1.10
2.1 --- a/server/src/fs_accessor.cc Sat Sep 14 01:26:59 2019 +0200
2.2 +++ b/server/src/fs_accessor.cc Mon Oct 07 15:24:20 2019 +0200
2.3 @@ -37,17 +37,8 @@
2.4
2.5 Fs_accessor::Fs_accessor(ext2_filsys fs, ext2_ino_t ino_file, int flags,
2.6 Pages *pages, size_t size)
2.7 -: Accessor(pages, size), _fs(fs), _ino_file(ino_file)
2.8 +: Accessor(pages, size), _fs(fs), _ino_file(ino_file), _flags(flags)
2.9 {
2.10 - struct ext2_inode inode_file;
2.11 -
2.12 - /* NOTE: Should handle failure appropriately. */
2.13 -
2.14 - if (!ext2fs_file_open(fs, ino_file, flags, &_file) &&
2.15 - !ext2fs_read_inode(fs, ino_file, &inode_file))
2.16 - {
2.17 - set_size(EXT2_I_SIZE(&inode_file));
2.18 - }
2.19 }
2.20
2.21
2.22 @@ -108,6 +99,18 @@
2.23 {
2.24 if (_irqs.empty())
2.25 {
2.26 + /* Open the file when the first attach operation occurs. */
2.27 +
2.28 + struct ext2_inode inode_file;
2.29 +
2.30 + /* NOTE: Should handle failure appropriately. */
2.31 +
2.32 + if (!ext2fs_file_open(_fs, _ino_file, _flags, &_file) &&
2.33 + !ext2fs_read_inode(_fs, _ino_file, &inode_file))
2.34 + {
2.35 + set_size(EXT2_I_SIZE(&inode_file));
2.36 + }
2.37 +
2.38 /* Create a semaphore and make the accessor initially available. */
2.39
2.40 l4_factory_create(l4re_env()->factory, L4_PROTO_SEMAPHORE, _semaphore);