- /* There may already be open file descriptors to this stream if
- * it's previously been opened read-only, but just now we're
- * opening it read-write. Identify those file descriptors and
- * change their lookup table entry pointers to point to the new
- * lookup table entry, and open staging file descriptors for
- * them.
- *
- * At the same time, we need to count the number of these opened
- * file descriptors to the new lookup table entry. If there's
- * an old lookup table entry, this number needs to be subtracted
- * from the fd's opened to the old entry. */
- for (u16 i = 0, j = 0; j < inode->i_num_opened_fds; i++) {
- struct wimfs_fd *fd;
- int raw_fd;
-
- fd = inode->i_fds[i];
- if (!fd)
- continue;
-
- j++;
-
- if (fd->f_stream_id != stream_id)
- continue;
-
- /* This is a readonly fd for the same stream. */
- fd->f_lte = new_lte;
- new_lte->num_opened_fds++;
- raw_fd = openat(ctx->staging_dir_fd, staging_file_name,
- O_RDONLY | O_NOFOLLOW);
- if (unlikely(raw_fd < 0)) {
- ret = -errno;
- goto out_revert_fd_changes;
- }
- filedes_init(&fd->f_staging_fd, raw_fd);
- }
- if (old_lte) {
- old_lte->num_opened_fds -= new_lte->num_opened_fds;
- old_lte->refcnt -= inode->i_nlink;
+ if (fd->f_stream_id != strm->stream_id)
+ continue;
+
+ /* This is a readonly fd for the same stream. */
+ fd->f_blob = new_blob;
+ new_blob->num_opened_fds++;
+ raw_fd = openat(ctx->staging_dir_fd, staging_file_name,
+ O_RDONLY | O_NOFOLLOW);
+ if (unlikely(raw_fd < 0)) {
+ ret = -errno;
+ goto out_revert_fd_changes;