[CRIU] [PATCH 1/2] protobuf: proto-file example for IPC semaphores
Kinsbursky Stanislav
skinsbursky at openvz.org
Thu May 24 11:34:21 EDT 2012
From: Stanislav Kinsbursky <skinsbursky at openvz.org>
This patch also includes build and link of protobuf facility.
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
Makefile | 11 ++++++++---
protobuf/Makefile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
protobuf/README | 3 +++
protobuf/ipc_sem.proto | 11 +++++++++++
4 files changed, 72 insertions(+), 3 deletions(-)
create mode 100644 protobuf/Makefile
create mode 100644 protobuf/README
create mode 100644 protobuf/ipc_sem.proto
-------------- next part --------------
diff --git a/Makefile b/Makefile
index f776f49..bc4d840 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
CFLAGS += -I./include
CFLAGS += -O0 -ggdb3
-LIBS += -lrt -lpthread
+LIBS += -lrt -lpthread -lprotobuf-c
DEFINES += -D_FILE_OFFSET_BITS=64
DEFINES += -D_GNU_SOURCE
@@ -75,13 +75,17 @@ all: $(PROGRAM)
$(E) " CC " $@
$(Q) $(CC) -S $(CFLAGS) -fverbose-asm $< -o $@
-$(PROGRAM): $(OBJS) | $(SYS-OBJ) $(PIE-GEN)
+$(PROGRAM): protobuf $(OBJS) | $(SYS-OBJ) $(PIE-GEN)
$(E) " LINK " $@
- $(Q) $(CC) $(CFLAGS) $(OBJS) $(LIBS) $(SYS-OBJ) -o $@
+ $(Q) $(CC) $(CFLAGS) $(OBJS) $(LIBS) $(SYS-OBJ) protobuf/protobuf-lib.o -o $@
%.d: %.c | $(SYS-OBJ) $(PIE-GEN)
$(Q) $(CC) -M -MT $(patsubst %.d,%.o,$@) $(CFLAGS) $< -o $@
+protobuf:
+ $(Q) $(MAKE) -C protobuf/ all
+.PHONY: protobuf
+
test-legacy: $(PROGRAM)
$(Q) $(MAKE) -C test/legacy all
.PHONY: test-legacy
@@ -111,6 +115,7 @@ clean: cleanpie cleansyscall
$(Q) $(RM) -f ./*.bin
$(Q) $(RM) -f ./$(PROGRAM)
$(Q) $(RM) -rf ./test/dump/
+ $(Q) $(MAKE) -C protobuf/ clean
$(Q) $(MAKE) -C test/legacy clean
$(Q) $(MAKE) -C test/zdtm cleandep
$(Q) $(MAKE) -C test/zdtm clean
diff --git a/protobuf/Makefile b/protobuf/Makefile
new file mode 100644
index 0000000..bf2a686
--- /dev/null
+++ b/protobuf/Makefile
@@ -0,0 +1,50 @@
+-include ../Makefile.inc
+
+CFLAGS += -I./include
+CFLAGS += -O0 -ggdb3
+
+DEFINES += -D_FILE_OFFSET_BITS=64
+DEFINES += -D_GNU_SOURCE
+
+ifneq ($(WERROR),0)
+ WARNINGS += -Werror
+endif
+
+ifeq ($(DEBUG),1)
+ DEFINES += -DCR_DEBUG
+endif
+
+WARNINGS += -Wall
+CFLAGS += $(WARNINGS) $(DEFINES)
+
+LIBRARY := protobuf-lib.o
+
+PROTO_FILES += ipc_sem.proto
+
+HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES))
+SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES))
+OBJS := $(patsubst %.c,%.o,$(SRCS))
+
+%.pb-c.c: %.proto
+ $(E) " PROTOBUF "$@
+ $(Q) protoc-c --c_out=./ $<
+
+%.o: %.c
+ $(E) " CC "$@
+ $(Q) $(CC) -c $(CFLAGS) $< -o $@
+
+.SECONDARY:
+
+LD_LIBRARY_PATH := /lib/
+
+$(LIBRARY): $(OBJS)
+ $(E) " LINK "$@
+ $(Q) ld -r -o $@ $(OBJS)
+
+all: $(LIBRARY)
+
+clean:
+ $(E) " CLEAN"
+ $(Q) rm -f $(SRCS) $(HDRS) $(OBJS) $(LIBRARY)
+
+.PHONY: all clean
diff --git a/protobuf/README b/protobuf/README
new file mode 100644
index 0000000..ae6eb1c
--- /dev/null
+++ b/protobuf/README
@@ -0,0 +1,3 @@
+Protobuf depends on packages:
+"protobuf-c"
+"protobuf-c-devel"
diff --git a/protobuf/ipc_sem.proto b/protobuf/ipc_sem.proto
new file mode 100644
index 0000000..52a029c
--- /dev/null
+++ b/protobuf/ipc_sem.proto
@@ -0,0 +1,11 @@
+message ipc_sem_entry
+{
+ required uint32 key = 1;
+ required uint32 uid = 2;
+ required uint32 gid = 3;
+ required uint32 cuid = 4;
+ required uint32 cgid = 5;
+ required uint32 mode = 6;
+ required uint32 id = 7;
+ required bytes values=8;
+}
More information about the CRIU
mailing list