[PATCH v2] Introduce a version6 of autofs interface, to fix design error.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch introduces a new autofs interface version, v6, which
is exactly the same as v5 but uses better defined packet structure
which does not change between architectures or platform bitness.
Old interface is supported still.

Signed-off-by: Michael Tokarev <mjt@xxxxxxxxxx>
Cc: Ian Kent <raven@xxxxxxxxxx>
Cc: Thomas Meyer <thomas@xxxxxxxx>
Cc: stable@xxxxxxxxxx
---
 fs/autofs4/waitq.c       |    6 ++++--
 include/linux/auto_fs4.h |   31 +++++++++++++++++++++++++++----
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index da8876d..97866e8 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -145,7 +145,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
 		break;
 	}
 	/*
-	 * Kernel protocol v5 packet for handling indirect and direct
+	 * Kernel protocol v5/v6 packet for handling indirect and direct
 	 * mount missing and expire requests
 	 */
 	case autofs_ptype_missing_indirect:
@@ -155,7 +155,9 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
 	{
 		struct autofs_v5_packet *packet = &pkt.v5_pkt.v5_packet;
 
-		pktsz = sizeof(*packet);
+		pktsz = (sbi->version == 5) ?
+			sizeof(struct autofs_v5_bad_packet) :
+			sizeof(struct autofs_v5_packet);
 
 		packet->wait_queue_token = wq->wait_queue_token;
 		packet->len = wq->name.len;
diff --git a/include/linux/auto_fs4.h b/include/linux/auto_fs4.h
index e02982f..fdef141 100644
--- a/include/linux/auto_fs4.h
+++ b/include/linux/auto_fs4.h
@@ -20,11 +20,11 @@
 #undef AUTOFS_MIN_PROTO_VERSION
 #undef AUTOFS_MAX_PROTO_VERSION
 
-#define AUTOFS_PROTO_VERSION		5
+#define AUTOFS_PROTO_VERSION		6
 #define AUTOFS_MIN_PROTO_VERSION	3
-#define AUTOFS_MAX_PROTO_VERSION	5
+#define AUTOFS_MAX_PROTO_VERSION	6
 
-#define AUTOFS_PROTO_SUBVERSION		2
+#define AUTOFS_PROTO_SUBVERSION		0
 
 /* Mask for expire behaviour */
 #define AUTOFS_EXP_IMMEDIATE		1
@@ -126,7 +126,7 @@ union autofs_packet_union {
 	struct autofs_packet_expire_multi expire_multi;
 };
 
-/* autofs v5 common packet struct */
+/* autofs v5/v6 common packet struct */
 struct autofs_v5_packet {
 	struct autofs_packet_hdr hdr;
 	autofs_wqt_t wait_queue_token;
@@ -138,6 +138,29 @@ struct autofs_v5_packet {
 	__u32 tgid;
 	__u32 len;
 	char name[NAME_MAX+1];
+
+	/* padding to make
+	 *   sizeof(autofs_v5_packet) % sizeof(__u64) == 0
+	 * on all arches */
+	char _pad[4];
+};
+
+/* earlier kernel interface used this structure for v5 packet,
+ * which is exactly the same as autofs_v5_packet above
+ * but does not have padding at the end.  The result was that
+ * sizeof it was 300 bytes on x86-32 and 304 bytes on x86-64.
+ * We keep it for compatibility with older userspace. */
+struct autofs_v5_bad_packet {
+	struct autofs_packet_hdr hdr;
+	autofs_wqt_t wait_queue_token;
+	__u32 dev;
+	__u64 ino;
+	__u32 uid;
+	__u32 gid;
+	__u32 pid;
+	__u32 tgid;
+	__u32 len;
+	char name[NAME_MAX+1];
 };
 
 typedef struct autofs_v5_packet autofs_packet_missing_indirect_t;
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe autofs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux Ext4]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux