chiark / gitweb /
memfd: move code from public library to src/shared
authorDaniel Mack <zonque@gmail.com>
Mon, 18 Aug 2014 08:55:49 +0000 (10:55 +0200)
committerDaniel Mack <zonque@gmail.com>
Mon, 18 Aug 2014 10:37:20 +0000 (12:37 +0200)
Don't expose generic kernel API via libsystemd, but keep the code internal
for our own usage.

Makefile.am
src/libsystemd/libsystemd.sym.m4
src/libsystemd/sd-bus/test-bus-zero-copy.c
src/shared/memfd.c [moved from src/libsystemd/sd-bus/sd-memfd.c with 89% similarity]
src/shared/memfd.h [moved from src/systemd/sd-memfd.h with 100% similarity]
src/systemd/sd-bus.h

index dbaed73..b9deaa6 100644 (file)
@@ -860,6 +860,8 @@ libsystemd_shared_la_SOURCES = \
        src/shared/copy.h \
        src/shared/base-filesystem.c \
        src/shared/base-filesystem.h \
+       src/shared/memfd.c \
+       src/shared/memfd.h \
        src/shared/nss-util.h
 
 nodist_libsystemd_shared_la_SOURCES = \
@@ -2382,7 +2384,6 @@ libsystemd_internal_la_SOURCES = \
        src/systemd/sd-bus.h \
        src/systemd/sd-bus-protocol.h \
        src/systemd/sd-bus-vtable.h \
-       src/systemd/sd-memfd.h \
        src/systemd/sd-utf8.h \
        src/systemd/sd-event.h \
        src/systemd/sd-rtnl.h \
@@ -2432,7 +2433,6 @@ libsystemd_internal_la_SOURCES = \
        src/libsystemd/sd-bus/bus-slot.h \
        src/libsystemd/sd-bus/bus-protocol.h \
        src/libsystemd/sd-bus/kdbus.h \
-       src/libsystemd/sd-bus/sd-memfd.c \
        src/libsystemd/sd-utf8/sd-utf8.c \
        src/libsystemd/sd-event/sd-event.c \
        src/libsystemd/sd-event/event-util.h \
@@ -2550,7 +2550,6 @@ pkginclude_HEADERS += \
        src/systemd/sd-bus.h \
        src/systemd/sd-bus-protocol.h \
        src/systemd/sd-bus-vtable.h \
-       src/systemd/sd-memfd.h \
        src/systemd/sd-utf8.h \
        src/systemd/sd-event.h \
        src/systemd/sd-rtnl.h \
index 1c24cad..415d89a 100644 (file)
@@ -359,20 +359,6 @@ global:
         sd_bus_track_first;
         sd_bus_track_next;
 
-        /* sd-memfd */
-        sd_memfd_new;
-        sd_memfd_new_and_map;
-        sd_memfd_free;
-        sd_memfd_get_fd;
-        sd_memfd_get_file;
-        sd_memfd_dup_fd;
-        sd_memfd_map;
-        sd_memfd_set_sealed;
-        sd_memfd_get_sealed;
-        sd_memfd_get_size;
-        sd_memfd_set_size;
-        sd_memfd_get_name;
-
         /* sd-event */
         sd_event_default;
         sd_event_new;
index 29e40aa..e4a87ab 100644 (file)
@@ -24,9 +24,9 @@
 
 #include "util.h"
 #include "log.h"
+#include "memfd.h"
 
 #include "sd-bus.h"
-#include "sd-memfd.h"
 #include "bus-message.h"
 #include "bus-error.h"
 #include "bus-kernel.h"
similarity index 89%
rename from src/libsystemd/sd-bus/sd-memfd.c
rename to src/shared/memfd.c
index 16d09e3..4dd70a2 100644 (file)
@@ -28,8 +28,8 @@
 #include "util.h"
 #include "bus-label.h"
 #include "missing.h"
+#include "memfd.h"
 
-#include "sd-memfd.h"
 #include "sd-bus.h"
 
 struct sd_memfd {
@@ -37,7 +37,7 @@ struct sd_memfd {
         FILE *f;
 };
 
-_public_ int sd_memfd_new(sd_memfd **m, const char *name) {
+int sd_memfd_new(sd_memfd **m, const char *name) {
 
         _cleanup_close_ int kdbus = -1;
         _cleanup_free_ char *g = NULL;
@@ -100,7 +100,7 @@ _public_ int sd_memfd_new(sd_memfd **m, const char *name) {
         return 0;
 }
 
-_public_ int sd_memfd_new_from_fd(sd_memfd **m, int fd) {
+int sd_memfd_new_from_fd(sd_memfd **m, int fd) {
         sd_memfd *n;
 
         assert_return(m, -EINVAL);
@@ -120,7 +120,7 @@ _public_ int sd_memfd_new_from_fd(sd_memfd **m, int fd) {
         return 0;
 }
 
-_public_ void sd_memfd_free(sd_memfd *m) {
+void sd_memfd_free(sd_memfd *m) {
         if (!m)
                 return;
 
@@ -132,13 +132,13 @@ _public_ void sd_memfd_free(sd_memfd *m) {
         free(m);
 }
 
-_public_ int sd_memfd_get_fd(sd_memfd *m) {
+int sd_memfd_get_fd(sd_memfd *m) {
         assert_return(m, -EINVAL);
 
         return m->fd;
 }
 
-_public_ int sd_memfd_get_file(sd_memfd *m, FILE **f) {
+int sd_memfd_get_file(sd_memfd *m, FILE **f) {
         assert_return(m, -EINVAL);
         assert_return(f, -EINVAL);
 
@@ -152,7 +152,7 @@ _public_ int sd_memfd_get_file(sd_memfd *m, FILE **f) {
         return 0;
 }
 
-_public_ int sd_memfd_dup_fd(sd_memfd *m) {
+int sd_memfd_dup_fd(sd_memfd *m) {
         int fd;
 
         assert_return(m, -EINVAL);
@@ -164,7 +164,7 @@ _public_ int sd_memfd_dup_fd(sd_memfd *m) {
         return fd;
 }
 
-_public_ int sd_memfd_map(sd_memfd *m, uint64_t offset, size_t size, void **p) {
+int sd_memfd_map(sd_memfd *m, uint64_t offset, size_t size, void **p) {
         void *q;
         int sealed;
 
@@ -184,7 +184,7 @@ _public_ int sd_memfd_map(sd_memfd *m, uint64_t offset, size_t size, void **p) {
         return 0;
 }
 
-_public_ int sd_memfd_set_sealed(sd_memfd *m) {
+int sd_memfd_set_sealed(sd_memfd *m) {
         int r;
 
         assert_return(m, -EINVAL);
@@ -196,7 +196,7 @@ _public_ int sd_memfd_set_sealed(sd_memfd *m) {
         return 0;
 }
 
-_public_ int sd_memfd_get_sealed(sd_memfd *m) {
+int sd_memfd_get_sealed(sd_memfd *m) {
         int r;
 
         assert_return(m, -EINVAL);
@@ -209,7 +209,7 @@ _public_ int sd_memfd_get_sealed(sd_memfd *m) {
                     (F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE);
 }
 
-_public_ int sd_memfd_get_size(sd_memfd *m, uint64_t *sz) {
+int sd_memfd_get_size(sd_memfd *m, uint64_t *sz) {
         int r;
         struct stat stat;
 
@@ -224,7 +224,7 @@ _public_ int sd_memfd_get_size(sd_memfd *m, uint64_t *sz) {
         return r;
 }
 
-_public_ int sd_memfd_set_size(sd_memfd *m, uint64_t sz) {
+int sd_memfd_set_size(sd_memfd *m, uint64_t sz) {
         int r;
 
         assert_return(m, -EINVAL);
@@ -236,7 +236,7 @@ _public_ int sd_memfd_set_size(sd_memfd *m, uint64_t sz) {
         return r;
 }
 
-_public_ int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, void **p) {
+int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, void **p) {
         sd_memfd *n;
         int r;
 
@@ -260,7 +260,7 @@ _public_ int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, voi
         return 0;
 }
 
-_public_ int sd_memfd_get_name(sd_memfd *m, char **name) {
+int sd_memfd_get_name(sd_memfd *m, char **name) {
         char path[sizeof("/proc/self/fd/") + DECIMAL_STR_MAX(int)], buf[FILENAME_MAX+1], *e;
         const char *delim, *end;
         _cleanup_free_ char *n = NULL;
similarity index 100%
rename from src/systemd/sd-memfd.h
rename to src/shared/memfd.h
index 3eedb44..a69cafb 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "sd-id128.h"
 #include "sd-event.h"
-#include "sd-memfd.h"
+#include "memfd.h"
 #include "_sd-common.h"
 
 _SD_BEGIN_DECLARATIONS;