return get_dentry(wim, buf, case_type);
}
-#ifdef WITH_FUSE
-/* Finds the dentry, lookup table entry, and stream index for a WIM file stream,
- * given a path name.
- *
- * Currently, lookups of this type are only needed if FUSE is enabled. */
-int
-wim_pathname_to_stream(WIMStruct *wim,
- const tchar *path,
- int lookup_flags,
- struct wim_dentry **dentry_ret,
- struct wim_lookup_table_entry **lte_ret,
- u16 *stream_idx_ret)
-{
- struct wim_dentry *dentry;
- struct wim_lookup_table_entry *lte;
- u16 stream_idx;
- const tchar *stream_name = NULL;
- struct wim_inode *inode;
- tchar *p = NULL;
-
- if (lookup_flags & LOOKUP_FLAG_ADS_OK) {
- stream_name = path_stream_name(path);
- if (stream_name) {
- p = (tchar*)stream_name - 1;
- *p = T('\0');
- }
- }
-
- dentry = get_dentry(wim, path, WIMLIB_CASE_SENSITIVE);
- if (p)
- *p = T(':');
- if (!dentry)
- return -errno;
-
- inode = dentry->d_inode;
-
- if (!inode->i_resolved)
- if (inode_resolve_streams(inode, wim->lookup_table, false))
- return -EIO;
-
- if (!(lookup_flags & LOOKUP_FLAG_DIRECTORY_OK)
- && inode_is_directory(inode))
- return -EISDIR;
-
- if (stream_name) {
- struct wim_ads_entry *ads_entry;
-
- ads_entry = inode_get_ads_entry(inode, stream_name);
- if (!ads_entry)
- return -errno;
-
- stream_idx = ads_entry - inode->i_ads_entries + 1;
- lte = ads_entry->lte;
- } else {
- lte = inode_unnamed_stream_resolved(inode, &stream_idx);
- }
- if (dentry_ret)
- *dentry_ret = dentry;
- if (lte_ret)
- *lte_ret = lte;
- if (stream_idx_ret)
- *stream_idx_ret = stream_idx;
- return 0;
-}
-#endif /* WITH_FUSE */
-
/* Creates an unlinked directory entry. */
int
new_dentry(const tchar *name, struct wim_dentry **dentry_ret)
return wimfs_get_context()->wim;
}
-static inline int
-get_lookup_flags(const struct wimfs_context *ctx)
-{
- return ctx->default_lookup_flags;
-}
-
/* Is write permission requested on the file? */
static inline bool
flags_writable(int open_flags)
return dentry->d_inode;
}
+/* Can look up named data stream with colon syntax */
+#define LOOKUP_FLAG_ADS_OK 0x01
+
+/* Can look up directory (otherwise get -ENOTDIR) */
+#define LOOKUP_FLAG_DIRECTORY_OK 0x02
+
+/*
+ * Translate a path into the corresponding dentry, lookup table entry, and
+ * stream index in the mounted WIM image.
+ *
+ * Returns 0 or a -errno code. All of @dentry_ret, @lte_ret, and
+ * @stream_idx_ret are optional.
+ */
+static int
+wim_pathname_to_stream(const struct wimfs_context *ctx, const char *path,
+ int lookup_flags,
+ struct wim_dentry **dentry_ret,
+ struct wim_lookup_table_entry **lte_ret,
+ u16 *stream_idx_ret)
+{
+ WIMStruct *wim = ctx->wim;
+ struct wim_dentry *dentry;
+ struct wim_lookup_table_entry *lte;
+ u16 stream_idx;
+ const tchar *stream_name = NULL;
+ struct wim_inode *inode;
+ tchar *p = NULL;
+
+ lookup_flags |= ctx->default_lookup_flags;
+
+ if (lookup_flags & LOOKUP_FLAG_ADS_OK) {
+ stream_name = path_stream_name(path);
+ if (stream_name) {
+ p = (tchar*)stream_name - 1;
+ *p = T('\0');
+ }
+ }
+
+ dentry = get_dentry(wim, path, WIMLIB_CASE_SENSITIVE);
+ if (p)
+ *p = T(':');
+ if (!dentry)
+ return -errno;
+
+ inode = dentry->d_inode;
+
+ if (!inode->i_resolved)
+ if (inode_resolve_streams(inode, wim->lookup_table, false))
+ return -EIO;
+
+ if (!(lookup_flags & LOOKUP_FLAG_DIRECTORY_OK)
+ && inode_is_directory(inode))
+ return -EISDIR;
+
+ if (stream_name) {
+ struct wim_ads_entry *ads_entry;
+
+ ads_entry = inode_get_ads_entry(inode, stream_name);
+ if (!ads_entry)
+ return -errno;
+
+ stream_idx = ads_entry - inode->i_ads_entries + 1;
+ lte = ads_entry->lte;
+ } else {
+ lte = inode_unnamed_stream_resolved(inode, &stream_idx);
+ }
+ if (dentry_ret)
+ *dentry_ret = dentry;
+ if (lte_ret)
+ *lte_ret = lte;
+ if (stream_idx_ret)
+ *stream_idx_ret = stream_idx;
+ return 0;
+}
+
/*
* Create a new file in the mounted WIM image.
*
struct wim_lookup_table_entry *lte;
int ret;
- ret = wim_pathname_to_stream(ctx->wim, path,
- get_lookup_flags(ctx) |
- LOOKUP_FLAG_DIRECTORY_OK,
+ ret = wim_pathname_to_stream(ctx, path, LOOKUP_FLAG_DIRECTORY_OK,
&dentry, <e, NULL);
if (ret)
return ret;
struct wimfs_fd *fd;
int ret;
- ret = wim_pathname_to_stream(ctx->wim, path, get_lookup_flags(ctx),
- &dentry, <e, &stream_idx);
+ ret = wim_pathname_to_stream(ctx, path, 0, &dentry, <e, &stream_idx);
if (ret)
return ret;
int ret;
int fd;
- ret = wim_pathname_to_stream(ctx->wim, path, get_lookup_flags(ctx),
- &dentry, <e, &stream_idx);
-
+ ret = wim_pathname_to_stream(ctx, path, 0, &dentry, <e, &stream_idx);
if (ret)
return ret;
u16 stream_idx;
int ret;
- ret = wim_pathname_to_stream(ctx->wim, path, get_lookup_flags(ctx),
- &dentry, NULL, &stream_idx);
-
+ ret = wim_pathname_to_stream(ctx, path, 0, &dentry, NULL, &stream_idx);
if (ret)
return ret;