aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs/src
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-07-02 19:50:05 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-07-10 09:22:04 +0200
commite7ecb1f92ae618a56ee8eabb6cbf98365de3695a (patch)
tree8d6d53df2c1654ecf5f4c587d8b7b2592a68c4f2 /lib/sqfs/src
parentec593e0b94656a5481f82ee0f33728ced297ac48 (diff)
Move sqfs_dir_entry_t code from libio into libsquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/src')
-rw-r--r--lib/sqfs/src/dir_entry.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/sqfs/src/dir_entry.c b/lib/sqfs/src/dir_entry.c
new file mode 100644
index 0000000..8290ac8
--- /dev/null
+++ b/lib/sqfs/src/dir_entry.c
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: LGPL-3.0-or-later */
+/*
+ * dir_entry.c
+ *
+ * Copyright (C) 2023 David Oberhollenzer <goliath@infraroot.at>
+ */
+#define SQFS_BUILDING_DLL
+#include "config.h"
+
+#include "sqfs/dir_entry.h"
+#include "compat.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+sqfs_dir_entry_t *sqfs_dir_entry_create(const char *name, sqfs_u16 mode,
+ sqfs_u16 flags)
+{
+ sqfs_dir_entry_t *out;
+ size_t len, name_len;
+
+ if (flags & ~SQFS_DIR_ENTRY_FLAG_ALL)
+ return NULL;
+
+ name_len = strlen(name);
+ if (SZ_ADD_OV(name_len, 1, &name_len))
+ return NULL;
+ if (SZ_ADD_OV(sizeof(*out), name_len, &len))
+ return NULL;
+
+ out = calloc(1, len);
+ if (out == NULL)
+ return NULL;
+
+ out->mode = mode;
+ out->flags = flags;
+ memcpy(out->name, name, name_len);
+ return out;
+}