linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] hfsplus: add on-disk layout declarations related to attributes tree
@ 2012-09-23 14:49 Vyacheslav Dubeyko
  2012-09-25  9:43 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Vyacheslav Dubeyko @ 2012-09-23 14:49 UTC (permalink / raw)
  To: linux-fsdevel, Andrew Morton, Christoph Hellwig, Al Viro; +Cc: Hin-Tak Leung

Hi,

This patch adds all neccessary on-disk layout declarations related to attributes file.

With the best regards,
Vyacheslav Dubeyko.
---
From: Vyacheslav Dubeyko <slava@dubeyko.com>
Subject: [PATCH v2 1/4] hfsplus: add on-disk layout declarations related to attributes tree

This patch adds all neccessary on-disk layout declarations related to attributes file.

Reported-by: Hin-Tak Leung <htl10@users.sourceforge.net>
Signed-off-by: Vyacheslav Dubeyko <slava@dubeyko.com>
---
 fs/hfsplus/hfsplus_raw.h |   72 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 67 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 fs/hfsplus/hfsplus_raw.h

diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h
old mode 100644
new mode 100755
index 921967e..56f393f
--- a/fs/hfsplus/hfsplus_raw.h
+++ b/fs/hfsplus/hfsplus_raw.h
@@ -52,13 +52,21 @@
 typedef __be32 hfsplus_cnid;
 typedef __be16 hfsplus_unichr;
 
+#define HFSPLUS_MAX_STRLEN 255
+#define HFSPLUS_ATTR_MAX_STRLEN 127
+
+#define HFSPLUS_STRING(name, max_len)		\
+struct hfsplus_##name {				\
+	__be16 length;				\
+	hfsplus_unichr unicode[max_len];	\
+} __packed;					\
+
 /* A "string" as used in filenames, etc. */
-struct hfsplus_unistr {
-	__be16 length;
-	hfsplus_unichr unicode[255];
-} __packed;
+HFSPLUS_STRING(unistr, HFSPLUS_MAX_STRLEN)
 
-#define HFSPLUS_MAX_STRLEN 255
+/* A "string" is used in attributes file
+   for name of extended attribute */
+HFSPLUS_STRING(attr_unistr, HFSPLUS_ATTR_MAX_STRLEN)
 
 /* POSIX permissions */
 struct hfsplus_perm {
@@ -291,6 +299,8 @@ struct hfsplus_cat_file {
 /* File attribute bits */
 #define HFSPLUS_FILE_LOCKED		0x0001
 #define HFSPLUS_FILE_THREAD_EXISTS	0x0002
+#define HFSPLUS_XATTR_EXISTS		0x0004
+#define HFSPLUS_ACL_EXISTS		0x0008
 
 /* HFS+ catalog thread (part of a cat_entry) */
 struct hfsplus_cat_thread {
@@ -327,11 +337,63 @@ struct hfsplus_ext_key {
 
 #define HFSPLUS_EXT_KEYLEN	sizeof(struct hfsplus_ext_key)
 
+#define HFSPLUS_XATTR_FINDER_INFO_NAME "com.apple.FinderInfo"
+#define HFSPLUS_XATTR_ACL_NAME "com.apple.system.Security"
+
+#define HFSPLUS_ATTR_INLINE_DATA 0x10
+#define HFSPLUS_ATTR_FORK_DATA   0x20
+#define HFSPLUS_ATTR_EXTENTS     0x30
+
+/* HFS+ attributes tree key */
+struct hfsplus_attr_key {
+	__be16 key_len;
+	__be16 pad;
+	hfsplus_cnid cnid;
+	__be32 start_block;
+	struct hfsplus_attr_unistr key_name;
+} __packed;
+
+#define HFSPLUS_ATTR_KEYLEN	sizeof(struct hfsplus_attr_key)
+
+/* HFS+ fork data attribute */
+struct hfsplus_attr_fork_data {
+	__be32 record_type;
+	__be32 reserved;
+	struct hfsplus_fork_raw the_fork;
+} __packed;
+
+/* HFS+ extension attribute */
+struct hfsplus_attr_extents {
+	__be32 record_type;
+	__be32 reserved;
+	struct hfsplus_extent extents;
+} __packed;
+
+#define HFSPLUS_MAX_INLINE_DATA_SIZE 3802
+
+/* HFS+ attribute inline data */
+struct hfsplus_attr_inline_data {
+	__be32 record_type;
+	__be32 reserved1;
+	u8 reserved2[6];
+	__be16 length;
+	u8 raw_bytes[HFSPLUS_MAX_INLINE_DATA_SIZE];
+} __packed;
+
+/* A data record in the attributes tree */
+typedef union {
+	__be32 record_type;
+	struct hfsplus_attr_fork_data fork_data;
+	struct hfsplus_attr_extents extents;
+	struct hfsplus_attr_inline_data inline_data;
+} __packed hfsplus_attr_entry;
+
 /* HFS+ generic BTree key */
 typedef union {
 	__be16 key_len;
 	struct hfsplus_cat_key cat;
 	struct hfsplus_ext_key ext;
+	struct hfsplus_attr_key attr;
 } __packed hfsplus_btree_key;
 
 #endif
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/4] hfsplus: add on-disk layout declarations related to attributes tree
  2012-09-23 14:49 [PATCH v2 1/4] hfsplus: add on-disk layout declarations related to attributes tree Vyacheslav Dubeyko
@ 2012-09-25  9:43 ` Christoph Hellwig
  2012-09-25 10:58   ` Vyacheslav Dubeyko
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2012-09-25  9:43 UTC (permalink / raw)
  To: Vyacheslav Dubeyko
  Cc: linux-fsdevel, Andrew Morton, Christoph Hellwig, Al Viro,
	Hin-Tak Leung

I really don't like the HFSPLUS_STRING macro, and with just two users
I don't see the point either.  Just declare the two structures
independently.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/4] hfsplus: add on-disk layout declarations related to attributes tree
  2012-09-25  9:43 ` Christoph Hellwig
@ 2012-09-25 10:58   ` Vyacheslav Dubeyko
  0 siblings, 0 replies; 3+ messages in thread
From: Vyacheslav Dubeyko @ 2012-09-25 10:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-fsdevel, Andrew Morton, Al Viro, Hin-Tak Leung

Hi,

On Tue, 2012-09-25 at 05:43 -0400, Christoph Hellwig wrote:
> I really don't like the HFSPLUS_STRING macro, and with just two users
> I don't see the point either.  Just declare the two structures
> independently.
> 

Ok. I agree. It will be corrected.

With the best regards,
Vyacheslav Dubeyko.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-25 10:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-23 14:49 [PATCH v2 1/4] hfsplus: add on-disk layout declarations related to attributes tree Vyacheslav Dubeyko
2012-09-25  9:43 ` Christoph Hellwig
2012-09-25 10:58   ` Vyacheslav Dubeyko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).