1.1 --- a/libfsserver/lib/files/file_pager.cc Fri Jul 16 00:38:55 2021 +0200
1.2 +++ b/libfsserver/lib/files/file_pager.cc Fri Jul 16 00:39:24 2021 +0200
1.3 @@ -51,6 +51,10 @@
1.4 void FilePager::close()
1.5 {
1.6 _paging->detach_pager(fileid, _mapper);
1.7 +
1.8 + /* Notify other users of the file. */
1.9 +
1.10 + _paging->notify_others(_endpoint, NOTIFY_PEER_CLOSED);
1.11 }
1.12
1.13
1.14 @@ -59,12 +63,29 @@
1.15
1.16 long FilePager::flush(offset_t populated_size, offset_t *size)
1.17 {
1.18 - return Pager::flush(populated_size, size);
1.19 + long err = Pager::flush(populated_size, size);
1.20 +
1.21 + if (_resized)
1.22 + {
1.23 + _paging->notify_others(_endpoint, NOTIFY_CONTENT_AVAILABLE);
1.24 + _resized = false;
1.25 + }
1.26 +
1.27 + return err;
1.28 }
1.29
1.30 long FilePager::resize(offset_t *size)
1.31 {
1.32 - return Pager::resize(size);
1.33 + offset_t old_size = get_data_size();
1.34 + long err = Pager::resize(size);
1.35 +
1.36 + /* If the size has changed, notify other users, but only after data has been
1.37 + flushed. */
1.38 +
1.39 + if (old_size < get_data_size())
1.40 + _resized = true;
1.41 +
1.42 + return err;
1.43 }
1.44
1.45 long FilePager::mmap(offset_t position, offset_t length, offset_t *start_pos,
1.46 @@ -84,4 +105,23 @@
1.47 return Pager::map(offset, hot_spot, flags, region);
1.48 }
1.49
1.50 +
1.51 +
1.52 +/* Subscribe to notifications. */
1.53 +
1.54 +long FilePager::subscribe(l4_cap_idx_t notifier, notify_flags_t flags)
1.55 +{
1.56 + /* Readers can subscribe to new data (at end), and pipe closed events.
1.57 + Writers can subscribe to new space and pipe closed events. */
1.58 +
1.59 + _endpoint = _paging->subscribe(notifier, flags);
1.60 + return L4_EOK;
1.61 +}
1.62 +
1.63 +long FilePager::unsubscribe(l4_cap_idx_t notifier)
1.64 +{
1.65 + _paging->unsubscribe(_endpoint, notifier);
1.66 + return L4_EOK;
1.67 +}
1.68 +
1.69 // vim: tabstop=4 expandtab shiftwidth=4