mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-05 21:37:15 +02:00
Recent kernel updates makes xenstore-read return ESRCH due to not having a transaction in progress when talking to xenbus, this makes sure that a transaction is always in place.
145 lines
3.5 KiB
Diff
145 lines
3.5 KiB
Diff
--- xen-4.7.0-orig/tools/xenstore/xenstore_client.c 2016-06-20 12:38:15.000000000 +0200
|
|
+++ xen-4.7.0/tools/xenstore/xenstore_client.c 2016-10-05 03:16:39.372927512 +0200
|
|
@@ -126,7 +126,7 @@
|
|
|
|
#define MIN(a, b) (((a) < (b))? (a) : (b))
|
|
|
|
-static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_perms)
|
|
+static void do_ls(struct xs_handle *h, xs_transaction_t xth, char *path, int cur_depth, int show_perms)
|
|
{
|
|
char **e;
|
|
char *newpath, *val;
|
|
@@ -135,12 +135,14 @@
|
|
unsigned int num, len;
|
|
|
|
newpath = malloc(STRING_MAX);
|
|
- if (!newpath)
|
|
+ if (!newpath) {
|
|
err(1, "malloc in do_ls");
|
|
+ }
|
|
|
|
- e = xs_directory(h, XBT_NULL, path, &num);
|
|
- if (e == NULL)
|
|
+ e = xs_directory(h, xth, path, &num);
|
|
+ if (e == NULL) {
|
|
err(1, "xs_directory (%s)", path);
|
|
+ }
|
|
|
|
for (i = 0; i<num; i++) {
|
|
char buf[MAX_STRLEN(unsigned int)+1];
|
|
@@ -167,7 +169,7 @@
|
|
|
|
/* Fetch value */
|
|
if ( newpath_len < STRING_MAX ) {
|
|
- val = xs_read(h, XBT_NULL, newpath, &len);
|
|
+ val = xs_read(h, xth, newpath, &len);
|
|
}
|
|
else {
|
|
/* Path was truncated and thus invalid */
|
|
@@ -200,7 +202,7 @@
|
|
free(val);
|
|
|
|
if (show_perms) {
|
|
- perms = xs_get_permissions(h, XBT_NULL, newpath, &nperms);
|
|
+ perms = xs_get_permissions(h, xth, newpath, &nperms);
|
|
if (perms == NULL) {
|
|
warn("\ncould not access permissions for %s", e[i]);
|
|
}
|
|
@@ -219,7 +221,7 @@
|
|
|
|
putchar('\n');
|
|
|
|
- do_ls(h, newpath, cur_depth+1, show_perms);
|
|
+ do_ls(h, xth, newpath, cur_depth+1, show_perms);
|
|
}
|
|
free(e);
|
|
free(newpath);
|
|
@@ -417,7 +419,7 @@
|
|
break;
|
|
}
|
|
case MODE_ls: {
|
|
- do_ls(xsh, argv[optind], 0, prefix);
|
|
+ do_ls(xsh, xth, argv[optind], 0, prefix);
|
|
optind++;
|
|
break;
|
|
}
|
|
@@ -505,7 +507,6 @@
|
|
int upto = 0;
|
|
int recurse = 0;
|
|
int nr_watches = -1;
|
|
- int transaction;
|
|
struct winsize ws;
|
|
enum mode mode;
|
|
|
|
@@ -612,43 +613,28 @@
|
|
}
|
|
}
|
|
|
|
- switch (mode) {
|
|
- case MODE_read:
|
|
- transaction = (argc - switch_argv - optind) > 1;
|
|
- break;
|
|
- case MODE_write:
|
|
- transaction = (argc - switch_argv - optind) > 2;
|
|
- break;
|
|
- case MODE_ls:
|
|
- case MODE_watch:
|
|
- transaction = 0;
|
|
- break;
|
|
- default:
|
|
- transaction = 1;
|
|
- break;
|
|
- }
|
|
-
|
|
- if ( mode == MODE_ls )
|
|
- {
|
|
+ if ( mode == MODE_ls ) {
|
|
memset(&ws, 0, sizeof(ws));
|
|
ret = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
|
|
- if (!ret)
|
|
+ if (!ret) {
|
|
max_width = ws.ws_col - 2;
|
|
}
|
|
+ }
|
|
|
|
xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
|
|
- if (xsh == NULL) err(1, "xs_open");
|
|
+ if (xsh == NULL) {
|
|
+ err(1, "xs_open");
|
|
+ }
|
|
|
|
again:
|
|
- if (transaction) {
|
|
xth = xs_transaction_start(xsh);
|
|
- if (xth == XBT_NULL)
|
|
+ if (xth == XBT_NULL) {
|
|
errx(1, "couldn't start transaction");
|
|
}
|
|
|
|
ret = perform(mode, optind, argc - switch_argv, argv + switch_argv, xsh, xth, prefix, tidy, upto, recurse, nr_watches);
|
|
|
|
- if (transaction && !xs_transaction_end(xsh, xth, ret)) {
|
|
+ if (!xs_transaction_end(xsh, xth, ret)) {
|
|
if (ret == 0 && errno == EAGAIN) {
|
|
output_pos = 0;
|
|
goto again;
|
|
@@ -656,14 +642,16 @@
|
|
errx(1, "couldn't end transaction");
|
|
}
|
|
|
|
- if (output_pos)
|
|
+ if (output_pos) {
|
|
printf("%s", output_buf);
|
|
+ }
|
|
|
|
free(output_buf);
|
|
free(ebuf.buf);
|
|
|
|
- if (xsh)
|
|
+ if (xsh) {
|
|
xs_close(xsh);
|
|
+ }
|
|
|
|
return ret;
|
|
}
|