+
+static void
+inode_set_stream_blob(struct wim_inode *inode, struct wim_inode_stream *strm,
+ struct blob_descriptor *new_blob)
+{
+ strm->_stream_blob = new_blob;
+ strm->stream_resolved = 1;
+ if (new_blob)
+ new_blob->refcnt += inode->i_nlink;
+}
+
+static void
+inode_unset_stream_blob(struct wim_inode *inode, struct wim_inode_stream *strm,
+ struct blob_table *blob_table)
+{
+ struct blob_descriptor *old_blob;
+
+ old_blob = stream_blob(strm, blob_table);
+ if (old_blob)
+ blob_subtract_refcnt(old_blob, blob_table, inode->i_nlink);
+ strm->_stream_blob = NULL;
+ strm->stream_resolved = 1;
+}
+
+/*
+ * Replace the blob associated with the specified stream.
+ *
+ * @inode
+ * The inode containing @strm
+ * @strm
+ * The stream whose data needs to be replaced
+ * @new_blob
+ * The new blob descriptor to assign
+ * @blob_table
+ * Pointer to the blob table in which data blobs are being indexed
+ */
+void
+inode_replace_stream_blob(struct wim_inode *inode,
+ struct wim_inode_stream *strm,
+ struct blob_descriptor *new_blob,
+ struct blob_table *blob_table)
+{
+ inode_unset_stream_blob(inode, strm, blob_table);
+ inode_set_stream_blob(inode, strm, new_blob);
+}
+