[Ocfs2-tools-devel] [PATCH 08/19] Ocfs2-tools: Add operation.c to o2info.

Tristan Ye tristan.ye at oracle.com
Tue Apr 13 19:50:08 PDT 2010


All of o2info's operations will be linked to a task list,
and executed one by one later, the real running code of
a new item for o2info is expected to be added there.

This patch only added the header of this file, which just
includes the headers and defines some helpers. detail operational
codes for each task of o2info will be posted in following
patches.

Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
 o2info/operations.c |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)
 create mode 100644 o2info/operations.c

diff --git a/o2info/operations.c b/o2info/operations.c
new file mode 100644
index 0000000..fbb9d18
--- /dev/null
+++ b/o2info/operations.c
@@ -0,0 +1,69 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * operations.c
+ *
+ * Implementations for all o2info's operation.
+ *
+ * Copyright (C) 2010 Oracle.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#define _XOPEN_SOURCE 600
+#define _LARGEFILE64_SOURCE
+#define _GNU_SOURCE /* Because libc really doesn't want us using O_DIRECT? */
+
+#include <errno.h>
+#include <sys/raw.h>
+#include <inttypes.h>
+
+#include "ocfs2/ocfs2.h"
+#include "ocfs2/bitops.h"
+#include "ocfs2-kernel/ocfs2_ioctl.h"
+#include "ocfs2-kernel/kernel-list.h"
+#include "ocfs2-kernel/fiemap.h"
+#include "tools-internal/verbose.h"
+
+#include "utils.h"
+
+static inline void __o2info_fill_request_header(struct ocfs2_info_request *req,
+						size_t size,
+						enum ocfs2_info_type code,
+						int flags)
+{
+	req->ir_magic = OCFS2_INFO_MAGIC;
+	req->ir_code = code;
+	req->ir_flags = flags;
+	req->ir_size = size;
+}
+
+/*
+ * Use marco to let sizeof() act on the full request type.
+ */
+#define o2info_fill_request(req, code, flags)		do {		\
+	memset(req, 0, sizeof(*req));					\
+	__o2info_fill_request_header((struct ocfs2_info_request *)req,	\
+				     sizeof(*req), code, flags);	\
+} while (0)
+
+extern void print_usage(int rc);
+extern int no_coherency;
+
+static void o2i_error(struct o2info_operation *op, const char *fmt, ...)
+{
+	va_list ap;
+
+	fprintf(stderr, "%s: ", op->to_name);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+
+	return;
+}
-- 
1.5.5




More information about the Ocfs2-tools-devel mailing list