1.1 --- a/libfsclient/lib/src/file.cc Mon Jun 07 00:50:14 2021 +0200
1.2 +++ b/libfsclient/lib/src/file.cc Fri Jul 02 23:53:13 2021 +0200
1.3 @@ -387,24 +387,55 @@
1.4
1.5 long file_notify_unsubscribe(file_t *file)
1.6 {
1.7 + if (l4_is_invalid_cap(file->irq))
1.8 + return -L4_EINVAL;
1.9 +
1.10 + l4_irq_detach(file->irq);
1.11 +
1.12 client_Notification notify(file->ref);
1.13
1.14 return notify.unsubscribe();
1.15 }
1.16
1.17 -/* Wait for notification events on a file. */
1.18 +/* Bind a file IRQ to the current thread. */
1.19 +
1.20 +long file_notify_bind_file(file_t *file)
1.21 +{
1.22 + if (l4_is_invalid_cap(file->irq))
1.23 + return -L4_EINVAL;
1.24
1.25 -long file_notify_wait(file_t *file)
1.26 + return ipc_bind_irq(file->irq, (l4_umword_t) file, pthread_l4_cap(pthread_self()));
1.27 +}
1.28 +
1.29 +/* Wait for a notification event on a file. */
1.30 +
1.31 +long file_notify_wait_file(file_t *file)
1.32 {
1.33 - long err = ipc_bind_irq(file->irq, (l4_umword_t) &file->irq, pthread_l4_cap(pthread_self()));
1.34 + long err = file_notify_bind_file(file);
1.35
1.36 if (err)
1.37 return err;
1.38
1.39 - l4_msgtag_t tag = l4_irq_receive(file->irq, L4_IPC_NEVER);
1.40 + return l4_error(l4_irq_receive(file->irq, L4_IPC_NEVER));
1.41 +}
1.42 +
1.43 +/* Wait for notification events on files. */
1.44
1.45 - l4_irq_detach(file->irq);
1.46 - return l4_error(tag);
1.47 +long file_notify_wait_files(file_t **file)
1.48 +{
1.49 + l4_umword_t label;
1.50 + l4_msgtag_t tag = l4_ipc_wait(l4_utcb(), &label, L4_IPC_NEVER);
1.51 + long err = l4_error(tag);
1.52 +
1.53 + if (err)
1.54 + *file = NULL;
1.55 + else
1.56 + {
1.57 + label = label & ~3UL;
1.58 + *file = reinterpret_cast<file_t *>(label);
1.59 + }
1.60 +
1.61 + return err;
1.62 }
1.63
1.64