X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Finode.c;h=6277f0c427d678e49959240963921a898e160ec3;hb=acbafe74cf4b44fd97eb3730494264b6085f03dd;hp=62cab6ed0b0f3989772a09aafe11c432f43efb84;hpb=15ded30b9bcce7ac0388dec90dd4d6ef3d6d1596;p=wimlib diff --git a/src/inode.c b/src/inode.c index 62cab6ed..6277f0c4 100644 --- a/src/inode.c +++ b/src/inode.c @@ -57,8 +57,8 @@ new_inode(struct wim_dentry *dentry, bool set_timestamps) inode->i_security_id = -1; /*inode->i_nlink = 0;*/ inode->i_not_rpfixed = 1; - INIT_LIST_HEAD(&inode->i_list); INIT_LIST_HEAD(&inode->i_dentry); + inode->i_streams = inode->i_embedded_streams; if (set_timestamps) { u64 now = now_as_wim_timestamp(); inode->i_creation_time = now; @@ -85,8 +85,6 @@ free_inode(struct wim_inode *inode) FREE(inode->i_streams); if (inode->i_extra) FREE(inode->i_extra); - /* HACK: This may instead delete the inode from i_list, but hlist_del() - * behaves the same as list_del(). */ if (!hlist_unhashed(&inode->i_hlist)) hlist_del(&inode->i_hlist); FREE(inode); @@ -437,7 +435,7 @@ inode_has_named_data_stream(const struct wim_inode *inode) * * If @force is %false: * If any of the needed blobs do not exist in @table, return - * WIMLIB_ERR_RESOURCE_NOT_FOUND and leave the inode unmodified. + * WIMLIB_ERR_RESOURCE_NOT_FOUND. * If @force is %true: * If any of the needed blobs do not exist in @table, allocate new blob * descriptors for them and insert them into @table. This does not, of @@ -452,14 +450,13 @@ int inode_resolve_streams(struct wim_inode *inode, struct blob_table *table, bool force) { - struct blob_descriptor *blobs[inode->i_num_streams]; - for (unsigned i = 0; i < inode->i_num_streams; i++) { + struct wim_inode_stream *strm = &inode->i_streams[i]; - if (inode->i_streams[i].stream_resolved) + if (strm->stream_resolved) continue; - const u8 *hash = stream_hash(&inode->i_streams[i]); + const u8 *hash = stream_hash(strm); struct blob_descriptor *blob = NULL; if (!is_zero_hash(hash)) { @@ -474,33 +471,12 @@ inode_resolve_streams(struct wim_inode *inode, struct blob_table *table, blob_table_insert(table, blob); } } - blobs[i] = blob; - } - - for (unsigned i = 0; i < inode->i_num_streams; i++) { - if (!inode->i_streams[i].stream_resolved) { - inode->i_streams[i]._stream_blob = blobs[i]; - inode->i_streams[i].stream_resolved = 1; - } + strm->_stream_blob = blob; + strm->stream_resolved = 1; } return 0; } -/* Undo the effects of inode_resolve_streams(). */ -void -inode_unresolve_streams(struct wim_inode *inode) -{ - for (unsigned i = 0; i < inode->i_num_streams; i++) { - - if (!inode->i_streams[i].stream_resolved) - continue; - - copy_hash(inode->i_streams[i]._stream_hash, - stream_hash(&inode->i_streams[i])); - inode->i_streams[i].stream_resolved = 0; - } -} - int blob_not_found_error(const struct wim_inode *inode, const u8 *hash) { @@ -553,7 +529,7 @@ inode_get_blob_for_unnamed_data_stream(const struct wim_inode *inode, { const struct wim_inode_stream *strm; - strm = inode_get_unnamed_stream(inode, STREAM_TYPE_DATA); + strm = inode_get_unnamed_data_stream(inode); if (!strm) return NULL; @@ -567,7 +543,7 @@ inode_get_blob_for_unnamed_data_stream_resolved(const struct wim_inode *inode) { const struct wim_inode_stream *strm; - strm = inode_get_unnamed_stream(inode, STREAM_TYPE_DATA); + strm = inode_get_unnamed_data_stream(inode); if (!strm) return NULL; @@ -584,7 +560,7 @@ inode_get_hash_of_unnamed_data_stream(const struct wim_inode *inode) { const struct wim_inode_stream *strm; - strm = inode_get_unnamed_stream(inode, STREAM_TYPE_DATA); + strm = inode_get_unnamed_data_stream(inode); if (!strm) return zero_hash;