* [PATCH] xenstore library revert and fixes
@ 2005-06-15 4:50 aq
2005-06-15 6:33 ` Rusty Russell
0 siblings, 1 reply; 2+ messages in thread
From: aq @ 2005-06-15 4:50 UTC (permalink / raw)
To: Rusty Russell, xen-devel
[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]
This patch reverts changes in the last patch on xenstore library
(which puts xs_ prefix to some private functions). Besides, it move
some part of xs_lib.h to xs.h, and fixes a typo on macro definition in
xs_lib.h (_XR_LIB_H). And xs_lib.h will not be installed into
/usr/include any more.
Is this fine, Rusty?
Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
$ diffstat xenstore.patch
Makefile | 2 +-
tools/xenstore/Makefile | 1 -
tools/xenstore/fake_libxc.c | 2 +-
tools/xenstore/xenstored_core.c | 18 +++++++++---------
tools/xenstore/xenstored_test.h | 2 +-
tools/xenstore/xs.c | 14 +++++++-------
tools/xenstore/xs.h | 22 +++++++++++++++++++---
tools/xenstore/xs_lib.c | 8 ++++----
tools/xenstore/xs_lib.h | 30 ++++++++----------------------
tools/xenstore/xs_random.c | 8 ++++----
tools/xenstore/xs_test.c | 4 ++--
11 files changed, 56 insertions(+), 55 deletions(-)
[-- Attachment #2: xenstore.patch --]
[-- Type: application/octet-stream, Size: 11872 bytes --]
===== Makefile 1.97 vs edited =====
--- 1.97/Makefile 2005-06-10 17:42:25 +09:00
+++ edited/Makefile 2005-06-15 12:11:53 +09:00
@@ -166,7 +166,7 @@
rm -rf $(D)/usr/$(LIBDIR)/share/xen $(D)/usr/$(LIBDIR)/libxenstore*
rm -rf $(D)/var/run/xen* $(D)/var/lib/xen*
rm -rf $(D)/usr/include/xcs_proto.h $(D)/usr/include/xc.h
- rm -rf $(D)/usr/include/xs_lib.h $(D)/usr/include/xs.h
+ rm -rf $(D)/usr/include/xs.h
rm -rf $(D)/usr/sbin/xcs $(D)/usr/sbin/xcsdump $(D)/usr/sbin/xen*
rm -rf $(D)/usr/sbin/netfix
rm -rf $(D)/usr/sbin/xfrd $(D)/usr/sbin/xm
===== tools/xenstore/Makefile 1.4 vs edited =====
--- 1.4/tools/xenstore/Makefile 2005-06-10 17:42:25 +09:00
+++ edited/tools/xenstore/Makefile 2005-06-15 11:57:42 +09:00
@@ -97,6 +97,5 @@
$(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
$(INSTALL_DATA) libxenstore.a $(DESTDIR)/usr/$(LIBDIR)
$(INSTALL_DATA) xs.h $(DESTDIR)/usr/include
- $(INSTALL_DATA) xs_lib.h $(DESTDIR)/usr/include
-include $(PROG_DEP)
===== tools/xenstore/fake_libxc.c 1.2 vs edited =====
--- 1.2/tools/xenstore/fake_libxc.c 2005-06-10 22:49:32 +09:00
+++ edited/tools/xenstore/fake_libxc.c 2005-06-15 12:02:53 +09:00
@@ -71,7 +71,7 @@
return fd;
memset(page, 0, sizeof(page));
- if (!xs_write_all(fd, page, sizeof(page)))
+ if (!write_all(fd, page, sizeof(page)))
barf_perror("Failed to write /tmp/xcmap page");
return fd;
===== tools/xenstore/xenstored_core.c 1.3 vs edited =====
--- 1.3/tools/xenstore/xenstored_core.c 2005-06-11 00:17:59 +09:00
+++ edited/tools/xenstore/xenstored_core.c 2005-06-15 12:06:03 +09:00
@@ -81,7 +81,7 @@
errno = ENOSPC;
return false;
}
- return xs_write_all(fd, contents, len);
+ return write_all(fd, contents, len);
}
int test_mkdir(const char *dir, int perms);
@@ -443,9 +443,9 @@
if (!strings)
return NULL;
- *num = xs_count_strings(strings, size);
+ *num = count_strings(strings, size);
ret = talloc_array(node, struct xs_permissions, *num);
- if (!xs_strings_to_perms(ret, *num, strings))
+ if (!strings_to_perms(ret, *num, strings))
corrupt(NULL, "Permissions corrupt for %s", node);
return ret;
@@ -460,7 +460,7 @@
char buffer[MAX_STRLEN(domid_t) + 1];
for (*len = 0, i = 0; i < num; i++) {
- if (!xs_perm_to_string(&perms[i], buffer))
+ if (!perm_to_string(&perms[i], buffer))
return NULL;
strings = talloc_realloc(node, strings, char,
@@ -506,7 +506,7 @@
if (!fd)
return NULL;
talloc_set_destructor(tmppath, destroy_path);
- if (!xs_write_all(*fd, contents, len))
+ if (!write_all(*fd, contents, len))
return NULL;
return tmppath;
@@ -721,14 +721,14 @@
permstr = perms_to_strings(dir, &perms, 1, &len);
fd = talloc_open(node_permfile(conn->transaction, node),
O_WRONLY|O_CREAT|O_EXCL, 0640);
- if (!fd || !xs_write_all(*fd, permstr, len))
+ if (!fd || !write_all(*fd, permstr, len))
return false;
if (data) {
char *datapath = node_datafile(conn->transaction, node);
fd = talloc_open(datapath, O_WRONLY|O_CREAT|O_EXCL, 0640);
- if (!fd || !xs_write_all(*fd, data, datalen))
+ if (!fd || !write_all(*fd, data, datalen))
return false;
}
@@ -878,7 +878,7 @@
char *node;
struct xs_permissions *perms;
- num = xs_count_strings(in->buffer, in->used);
+ num = count_strings(in->buffer, in->used);
if (num < 2)
return send_error(conn, EINVAL);
@@ -898,7 +898,7 @@
return send_error(conn, errno);
perms = talloc_array(node, struct xs_permissions, num);
- if (!xs_strings_to_perms(perms, num, in->buffer))
+ if (!strings_to_perms(perms, num, in->buffer))
return send_error(conn, errno);
if (!set_perms(conn->transaction, node, perms, num))
===== tools/xenstore/xenstored_test.h 1.2 vs edited =====
--- 1.2/tools/xenstore/xenstored_test.h 2005-06-10 22:49:32 +09:00
+++ edited/tools/xenstore/xenstored_test.h 2005-06-15 12:02:53 +09:00
@@ -21,7 +21,7 @@
#ifdef TESTING
bool test_write_all(int fd, void *contents, unsigned int len);
-#define xs_write_all test_write_all
+#define write_all test_write_all
int test_mkdir(const char *dir, int perms);
#define mkdir test_mkdir
===== tools/xenstore/xs.c 1.2 vs edited =====
--- 1.2/tools/xenstore/xs.c 2005-06-10 22:49:32 +09:00
+++ edited/tools/xenstore/xs.c 2005-06-15 12:06:03 +09:00
@@ -118,7 +118,7 @@
#ifdef XSTEST
#define read_all read_all_choice
-#define xs_write_all write_all_choice
+#define write_all write_all_choice
#endif
static int get_error(const char *errorstring)
@@ -179,11 +179,11 @@
ignorepipe.sa_flags = 0;
sigaction(SIGPIPE, &ignorepipe, &oldact);
- if (!xs_write_all(h->fd, &msg, sizeof(msg)))
+ if (!write_all(h->fd, &msg, sizeof(msg)))
goto fail;
for (i = 0; i < num_vecs; i++)
- if (!xs_write_all(h->fd, iovec[i].iov_base, iovec[i].iov_len))
+ if (!write_all(h->fd, iovec[i].iov_base, iovec[i].iov_len))
goto fail;
/* Watches can have fired before reply comes: daemon detects
@@ -253,7 +253,7 @@
return NULL;
/* Count the strings. */
- *num = xs_count_strings(strings, len);
+ *num = count_strings(strings, len);
/* Transfer to one big alloc for easy freeing. */
ret = malloc(*num * sizeof(char *) + len);
@@ -342,7 +342,7 @@
return NULL;
/* Count the strings: each one perms then domid. */
- *num = xs_count_strings(strings, len);
+ *num = count_strings(strings, len);
/* Transfer to one big alloc for easy freeing. */
ret = malloc(*num * sizeof(struct xs_permissions));
@@ -351,7 +351,7 @@
return NULL;
}
- if (!xs_strings_to_perms(ret, *num, strings)) {
+ if (!strings_to_perms(ret, *num, strings)) {
free_no_errno(ret);
ret = NULL;
}
@@ -376,7 +376,7 @@
for (i = 0; i < num_perms; i++) {
char buffer[MAX_STRLEN(domid_t)+1];
- if (!xs_perm_to_string(&perms[i], buffer))
+ if (!perm_to_string(&perms[i], buffer))
goto unwind;
iov[i+1].iov_base = strdup(buffer);
===== tools/xenstore/xs.h 1.1 vs edited =====
--- 1.1/tools/xenstore/xs.h 2005-06-07 19:57:29 +09:00
+++ edited/tools/xenstore/xs.h 2005-06-15 13:22:36 +09:00
@@ -1,8 +1,7 @@
-#ifndef _XS_H
-#define _XS_H
/*
Xen Store Daemon providing simple tree-like database.
Copyright (C) 2005 Rusty Russell IBM Corporation
+ Modifies 2005 Nguyen Anh Quynh <aquynh@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,9 +17,26 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef _XS_H
+#define _XS_H
+
+#include <xc.h>
/* On failure, these routines set errno. */
-#include "xs_lib.h"
+enum xs_perm_type {
+ XS_PERM_NONE = 0,
+ XS_PERM_READ = 1,
+ XS_PERM_WRITE = 2,
+ /* Internal use. */
+ XS_PERM_CREATE = 4,
+ XS_PERM_OWNER = 8
+};
+
+struct xs_permissions
+{
+ domid_t id;
+ enum xs_perm_type perms;
+};
struct xs_handle;
===== tools/xenstore/xs_lib.c 1.2 vs edited =====
--- 1.2/tools/xenstore/xs_lib.c 2005-06-10 22:49:32 +09:00
+++ edited/tools/xenstore/xs_lib.c 2005-06-15 12:06:03 +09:00
@@ -48,7 +48,7 @@
}
/* Simple routines for writing to sockets, etc. */
-bool xs_write_all(int fd, const void *data, unsigned int len)
+bool write_all(int fd, const void *data, unsigned int len)
{
while (len) {
int done;
@@ -66,7 +66,7 @@
}
/* Convert strings to permissions. False if a problem. */
-bool xs_strings_to_perms(struct xs_permissions *perms, unsigned int num,
+bool strings_to_perms(struct xs_permissions *perms, unsigned int num,
const char *strings)
{
const char *p;
@@ -104,7 +104,7 @@
}
/* Convert permissions to a string (up to len MAX_STRLEN(domid_t)+1). */
-bool xs_perm_to_string(const struct xs_permissions *perm, char *buffer)
+bool perm_to_string(const struct xs_permissions *perm, char *buffer)
{
switch (perm->perms) {
case XS_PERM_WRITE:
@@ -128,7 +128,7 @@
}
/* Given a string and a length, count how many strings (nul terms). */
-unsigned int xs_count_strings(const char *strings, unsigned int len)
+unsigned int count_strings(const char *strings, unsigned int len)
{
unsigned int num;
const char *p;
===== tools/xenstore/xs_lib.h 1.2 vs edited =====
--- 1.2/tools/xenstore/xs_lib.h 2005-06-10 22:49:32 +09:00
+++ edited/tools/xenstore/xs_lib.h 2005-06-15 12:22:04 +09:00
@@ -1,5 +1,3 @@
-#ifndef _XR_LIB_H
-#define _XR_LIB_H
/*
Common routines between Xen store user library and daemon.
Copyright (C) 2005 Rusty Russell IBM Corporation
@@ -18,26 +16,14 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef _XS_LIB_H
+#define _XS_LIB_H
+
#include <stdbool.h>
#include <limits.h>
-#include <xc.h>
+#include "xs.h"
/* Bitmask of permissions. */
-enum xs_perm_type {
- XS_PERM_NONE = 0,
- XS_PERM_READ = 1,
- XS_PERM_WRITE = 2,
- /* Internal use. */
- XS_PERM_CREATE = 4,
- XS_PERM_OWNER = 8,
-};
-
-struct xs_permissions
-{
- domid_t id;
- enum xs_perm_type perms;
-};
-
/* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */
#define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
@@ -48,16 +34,16 @@
const char *xs_daemon_transactions(void);
/* Simple write function: loops for you. */
-bool xs_write_all(int fd, const void *data, unsigned int len);
+bool write_all(int fd, const void *data, unsigned int len);
/* Convert strings to permissions. False if a problem. */
-bool xs_strings_to_perms(struct xs_permissions *perms, unsigned int num,
+bool strings_to_perms(struct xs_permissions *perms, unsigned int num,
const char *strings);
/* Convert permissions to a string (up to len MAX_STRLEN(domid_t)+1). */
-bool xs_perm_to_string(const struct xs_permissions *perm, char *buffer);
+bool perm_to_string(const struct xs_permissions *perm, char *buffer);
/* Given a string and a length, count how many strings (nul terms). */
-unsigned int xs_count_strings(const char *strings, unsigned int len);
+unsigned int count_strings(const char *strings, unsigned int len);
#endif /* _XS_LIB_H */
===== tools/xenstore/xs_random.c 1.2 vs edited =====
--- 1.2/tools/xenstore/xs_random.c 2005-06-10 22:49:32 +09:00
+++ edited/tools/xenstore/xs_random.c 2005-06-15 12:06:03 +09:00
@@ -223,10 +223,10 @@
release_file(perms, size);
return ret;
}
- *num = xs_count_strings(perms, size);
+ *num = count_strings(perms, size);
ret = new_array(struct xs_permissions, *num);
- if (!xs_strings_to_perms(ret, *num, perms))
+ if (!strings_to_perms(ret, *num, perms))
barf("Reading permissions from %s", permfile);
release_file(perms, size);
return ret;
@@ -267,7 +267,7 @@
for (i = 0; i < num; i++) {
char buffer[100];
- if (!xs_perm_to_string(&perms[i], buffer)) {
+ if (!perm_to_string(&perms[i], buffer)) {
int saved_errno = errno;
close(fd);
errno = saved_errno;
@@ -536,7 +536,7 @@
ret = talloc_asprintf_append(ret, "%s%s: ", spacing, dir[i]);
for (j = 0; j < numperms; j++) {
char buffer[100];
- if (!xs_perm_to_string(&perms[j], buffer))
+ if (!perm_to_string(&perms[j], buffer))
barf("perm to string");
ret = talloc_asprintf_append(ret, "%s ", buffer);
}
===== tools/xenstore/xs_test.c 1.3 vs edited =====
--- 1.3/tools/xenstore/xs_test.c 2005-06-11 00:17:59 +09:00
+++ edited/tools/xenstore/xs_test.c 2005-06-15 12:05:15 +09:00
@@ -153,7 +153,7 @@
{
if (fd == -2)
return write_all_shmem(fd, data, len);
- return xs_write_all(fd, data, len);
+ return write_all(fd, data, len);
}
/* We want access to internal functions. */
@@ -491,7 +491,7 @@
printf("%s%s: ", spacing, dir[i]);
for (j = 0; j < numperms; j++) {
char buffer[100];
- if (!xs_perm_to_string(&perms[j], buffer))
+ if (!perm_to_string(&perms[j], buffer))
barf("perm to string");
printf("%s ", buffer);
}
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] xenstore library revert and fixes
2005-06-15 4:50 [PATCH] xenstore library revert and fixes aq
@ 2005-06-15 6:33 ` Rusty Russell
0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2005-06-15 6:33 UTC (permalink / raw)
To: aq; +Cc: xen-devel
On Tue, 2005-06-14 at 21:50 -0700, aq wrote:
> This patch reverts changes in the last patch on xenstore library
> (which puts xs_ prefix to some private functions). Besides, it move
> some part of xs_lib.h to xs.h, and fixes a typo on macro definition in
> xs_lib.h (_XR_LIB_H). And xs_lib.h will not be installed into
> /usr/include any more.
>
> Is this fine, Rusty?
Sure, looks good, but crosses over a patch which I just sent (large, so
off-list) which syncs the store with the latest CVS version in Mike
Wray's tree, so it might not apply cleanly...
Thanks!
Rusty.
--
A bad analogy is like a leaky screwdriver -- Richard Braakman
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-06-15 6:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-15 4:50 [PATCH] xenstore library revert and fixes aq
2005-06-15 6:33 ` Rusty Russell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.