ia64/xen-unstable

changeset 6967:f7a7f8f2e6e4

Remove iflag argument to xs_write
xs_write with O_CREAT|O_EXCL causes problems over daemon restarts, since
it's not idempotent.
It turns out noone really needs the flags word at all, so get rid of it.
It's now as if everyone specified "O_CREAT".
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon Sep 19 14:34:30 2005 +0000 (2005-09-19)
parents a5d67e3fbff1
children 0a2cc72ee6e4
files tools/blktap/xenbus.c tools/console/daemon/io.c tools/python/xen/lowlevel/xs/xs.c tools/python/xen/xend/xenstore/xsnode.py tools/python/xen/xend/xenstore/xstransact.py tools/xenstore/testsuite/01simple.test tools/xenstore/testsuite/02directory.test tools/xenstore/testsuite/03write.test tools/xenstore/testsuite/04rm.test tools/xenstore/testsuite/05filepermissions.test tools/xenstore/testsuite/06dirpermissions.test tools/xenstore/testsuite/07watch.test tools/xenstore/testsuite/08transaction.slowtest tools/xenstore/testsuite/08transaction.test tools/xenstore/testsuite/09domain.test tools/xenstore/testsuite/10domain-homedir.test tools/xenstore/testsuite/11domain-watch.test tools/xenstore/testsuite/12readonly.test tools/xenstore/testsuite/13watch-ack.test tools/xenstore/testsuite/14complexperms.test tools/xenstore/testsuite/15nowait.test tools/xenstore/testsuite/16block-watch-crash.test tools/xenstore/xenstored_core.c tools/xenstore/xs.c tools/xenstore/xs.h tools/xenstore/xs_crashme.c tools/xenstore/xs_random.c tools/xenstore/xs_stress.c tools/xenstore/xs_test.c
line diff
     1.1 --- a/tools/blktap/xenbus.c	Mon Sep 19 14:25:29 2005 +0000
     1.2 +++ b/tools/blktap/xenbus.c	Mon Sep 19 14:34:30 2005 +0000
     1.3 @@ -92,7 +92,7 @@ int xs_printf(struct xs_handle *h, const
     1.4          if ((path == NULL) || (buf == NULL))
     1.5              return 0;
     1.6  
     1.7 -        ret = xs_write(h, path, buf, strlen(buf)+1, O_CREAT);
     1.8 +        ret = xs_write(h, path, buf, strlen(buf)+1);
     1.9  
    1.10          free(buf);
    1.11          free(path);
     2.1 --- a/tools/console/daemon/io.c	Mon Sep 19 14:25:29 2005 +0000
     2.2 +++ b/tools/console/daemon/io.c	Mon Sep 19 14:34:30 2005 +0000
     2.3 @@ -165,7 +165,7 @@ static int domain_create_tty(struct doma
     2.4  		success = asprintf(&path, "%s/tty", dom->conspath) != -1;
     2.5  		if (!success)
     2.6  			goto out;
     2.7 -		success = xs_write(xs, path, slave, strlen(slave), O_CREAT);
     2.8 +		success = xs_write(xs, path, slave, strlen(slave));
     2.9  		free(path);
    2.10  		if (!success)
    2.11  			goto out;
     3.1 --- a/tools/python/xen/lowlevel/xs/xs.c	Mon Sep 19 14:25:29 2005 +0000
     3.2 +++ b/tools/python/xen/lowlevel/xs/xs.c	Mon Sep 19 14:34:30 2005 +0000
     3.3 @@ -116,8 +116,6 @@ static PyObject *xspy_read(PyObject *sel
     3.4  	"Write data to a path.\n"				\
     3.5  	" path   [string] : xenstore path to write to\n."	\
     3.6  	" data   [string] : data to write.\n"			\
     3.7 -	" create [int]    : create flag, default 0.\n"		\
     3.8 -	" excl   [int]    : exclusive flag, default 0.\n"	\
     3.9  	"\n"							\
    3.10  	"Returns None on success.\n"				\
    3.11  	"Raises RuntimeError on error.\n"			\
    3.12 @@ -125,30 +123,23 @@ static PyObject *xspy_read(PyObject *sel
    3.13  
    3.14  static PyObject *xspy_write(PyObject *self, PyObject *args, PyObject *kwds)
    3.15  {
    3.16 -    static char *kwd_spec[] = { "path", "data", "create", "excl", NULL };
    3.17 -    static char *arg_spec = "ss#|ii";
    3.18 +    static char *kwd_spec[] = { "path", "data", NULL };
    3.19 +    static char *arg_spec = "ss#";
    3.20      char *path = NULL;
    3.21      char *data = NULL;
    3.22      int data_n = 0;
    3.23 -    int create = 0;
    3.24 -    int excl = 0;
    3.25  
    3.26      struct xs_handle *xh = xshandle(self);
    3.27      PyObject *val = NULL;
    3.28 -    int flags = 0;
    3.29      int xsval = 0;
    3.30  
    3.31      if (!xh)
    3.32          goto exit;
    3.33      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
    3.34 -                                     &path, &data, &data_n, &create, &excl))
    3.35 +                                     &path, &data, &data_n))
    3.36          goto exit;
    3.37 -    if (create)
    3.38 -        flags |= O_CREAT;
    3.39 -    if (excl)
    3.40 -        flags |= O_EXCL;
    3.41      Py_BEGIN_ALLOW_THREADS
    3.42 -    xsval = xs_write(xh, path, data, data_n, flags);
    3.43 +    xsval = xs_write(xh, path, data, data_n);
    3.44      Py_END_ALLOW_THREADS
    3.45      if (!xsval) {
    3.46          PyErr_SetFromErrno(PyExc_RuntimeError);
     4.1 --- a/tools/python/xen/xend/xenstore/xsnode.py	Mon Sep 19 14:25:29 2005 +0000
     4.2 +++ b/tools/python/xen/xend/xenstore/xsnode.py	Mon Sep 19 14:34:30 2005 +0000
     4.3 @@ -255,7 +255,7 @@ class XenStore:
     4.4              if x == "": continue
     4.5              p = os.path.join(p, x)
     4.6              if not self.exists(p):
     4.7 -                self.getxs().write(p, "", create=True)
     4.8 +                self.getxs().write(p, "")
     4.9  
    4.10      def read(self, path):
    4.11          try:
    4.12 @@ -266,13 +266,12 @@ class XenStore:
    4.13              else:
    4.14                  raise
    4.15  
    4.16 -    def create(self, path, excl=False):
    4.17 -        self.write(path, "", create=True, excl=excl)
    4.18 +    def create(self, path):
    4.19 +        self.write(path, "")
    4.20  
    4.21 -    def write(self, path, data, create=True, excl=False):
    4.22 -        self.mkdirs(path)
    4.23 +    def write(self, path, data):
    4.24          try:
    4.25 -            self.getxs().write(path, data, create=create, excl=excl)
    4.26 +            self.getxs().write(path, data)
    4.27          except Exception, ex:
    4.28              raise
    4.29  
     5.1 --- a/tools/python/xen/xend/xenstore/xstransact.py	Mon Sep 19 14:25:29 2005 +0000
     5.2 +++ b/tools/python/xen/xend/xenstore/xstransact.py	Mon Sep 19 14:34:30 2005 +0000
     5.3 @@ -53,13 +53,11 @@ class xstransact:
     5.4              ret.append(self._read(key))
     5.5          return ret
     5.6  
     5.7 -    def _write(self, key, data, create=True, excl=False):
     5.8 +    def _write(self, key, data):
     5.9          path = "%s/%s" % (self.path, key)
    5.10 -        xshandle().write(path, data, create=create, excl=excl)
    5.11 +        xshandle().write(path, data)
    5.12  
    5.13      def write(self, *args, **opts):
    5.14 -        create = opts.get('create') or True
    5.15 -        excl = opts.get('excl') or False
    5.16          if len(args) == 0:
    5.17              raise TypeError
    5.18          if isinstance(args[0], dict):
    5.19 @@ -68,19 +66,18 @@ class xstransact:
    5.20                      raise TypeError
    5.21                  for key in d.keys():
    5.22                      try:
    5.23 -                        self._write(key, d[key], create, excl)
    5.24 +                        self._write(key, d[key])
    5.25                      except TypeError, msg:
    5.26                          raise TypeError('Writing %s: %s: %s' %
    5.27                                          (key, str(d[key]), msg))
    5.28 -                        
    5.29          elif isinstance(args[0], list):
    5.30              for l in args:
    5.31                  if not len(l) == 2:
    5.32                      raise TypeError
    5.33 -                self._write(l[0], l[1], create, excl)
    5.34 +                self._write(l[0], l[1])
    5.35          elif len(args) % 2 == 0:
    5.36              for i in range(len(args) / 2):
    5.37 -                self._write(args[i * 2], args[i * 2 + 1], create, excl)
    5.38 +                self._write(args[i * 2], args[i * 2 + 1])
    5.39          else:
    5.40              raise TypeError
    5.41  
     6.1 --- a/tools/xenstore/testsuite/01simple.test	Mon Sep 19 14:25:29 2005 +0000
     6.2 +++ b/tools/xenstore/testsuite/01simple.test	Mon Sep 19 14:34:30 2005 +0000
     6.3 @@ -1,4 +1,4 @@
     6.4  # Create an entry, read it.
     6.5 -write /test create contents
     6.6 +write /test contents
     6.7  expect contents
     6.8  read /test
     7.1 --- a/tools/xenstore/testsuite/02directory.test	Mon Sep 19 14:25:29 2005 +0000
     7.2 +++ b/tools/xenstore/testsuite/02directory.test	Mon Sep 19 14:34:30 2005 +0000
     7.3 @@ -3,7 +3,7 @@ expect tool
     7.4  dir /
     7.5  
     7.6  # Create a file.
     7.7 -write /test create contents
     7.8 +write /test contents
     7.9  
    7.10  # Directory shows it.
    7.11  expect test
    7.12 @@ -21,7 +21,7 @@ dir /
    7.13  dir /dir
    7.14  
    7.15  # Create a file, check it exists.
    7.16 -write /dir/test2 create contents2
    7.17 +write /dir/test2 contents2
    7.18  expect test2
    7.19  dir /dir
    7.20  expect contents2
     8.1 --- a/tools/xenstore/testsuite/03write.test	Mon Sep 19 14:25:29 2005 +0000
     8.2 +++ b/tools/xenstore/testsuite/03write.test	Mon Sep 19 14:34:30 2005 +0000
     8.3 @@ -1,31 +1,20 @@
     8.4 -# Write without create fails.
     8.5 -expect write failed: No such file or directory
     8.6 -write /test none contents
     8.7 -
     8.8 -# Exclusive write succeeds
     8.9 -write /test excl contents
    8.10 +# Write succeeds
    8.11 +write /test contents
    8.12  expect contents
    8.13  read /test
    8.14  
    8.15 -# Exclusive write fails to overwrite.
    8.16 -expect write failed: File exists
    8.17 -write /test excl contents
    8.18 -
    8.19 -# Non-exclusive overwrite succeeds.
    8.20 -write /test none contents2
    8.21 +# Overwrite succeeds.
    8.22 +write /test contents2
    8.23  expect contents2
    8.24  read /test
    8.25 -write /test create contents3
    8.26 -expect contents3
    8.27 -read /test
    8.28  
    8.29  # Write should implicitly create directories
    8.30 -write /dir/test create contents
    8.31 +write /dir/test contents
    8.32  expect test
    8.33  dir /dir
    8.34  expect contents
    8.35  read /dir/test
    8.36 -write /dir/1/2/3/4 excl contents4
    8.37 +write /dir/1/2/3/4 contents4
    8.38  expect test
    8.39  expect 1
    8.40  dir /dir
     9.1 --- a/tools/xenstore/testsuite/04rm.test	Mon Sep 19 14:25:29 2005 +0000
     9.2 +++ b/tools/xenstore/testsuite/04rm.test	Mon Sep 19 14:34:30 2005 +0000
     9.3 @@ -4,7 +4,7 @@ expect rm failed: No such file or direct
     9.4  rm /dir/test
     9.5  
     9.6  # Create file and remove it
     9.7 -write /test excl contents
     9.8 +write /test contents
     9.9  rm /test
    9.10  
    9.11  # Create directory and remove it.
    9.12 @@ -13,5 +13,5 @@ rm /dir
    9.13  
    9.14  # Create directory, create file, remove all.
    9.15  mkdir /dir
    9.16 -write /dir/test excl contents
    9.17 +write /dir/test contents
    9.18  rm /dir
    10.1 --- a/tools/xenstore/testsuite/05filepermissions.test	Mon Sep 19 14:25:29 2005 +0000
    10.2 +++ b/tools/xenstore/testsuite/05filepermissions.test	Mon Sep 19 14:34:30 2005 +0000
    10.3 @@ -5,7 +5,7 @@ expect getperm failed: No such file or d
    10.4  getperm /dir/test
    10.5  
    10.6  # Create file: inherits from root (0 READ)
    10.7 -write /test excl contents
    10.8 +write /test contents
    10.9  expect 0 READ
   10.10  getperm /test
   10.11  setid 1
   10.12 @@ -14,7 +14,7 @@ getperm /test
   10.13  expect contents
   10.14  read /test
   10.15  expect write failed: Permission denied
   10.16 -write /test none contents
   10.17 +write /test contents
   10.18  
   10.19  # Take away read access to file.
   10.20  setid 0
   10.21 @@ -25,7 +25,7 @@ getperm /test
   10.22  expect read failed: Permission denied
   10.23  read /test
   10.24  expect write failed: Permission denied
   10.25 -write /test none contents
   10.26 +write /test contents
   10.27  
   10.28  # Grant everyone write access to file.
   10.29  setid 0
   10.30 @@ -35,7 +35,7 @@ expect getperm failed: Permission denied
   10.31  getperm /test
   10.32  expect read failed: Permission denied
   10.33  read /test
   10.34 -write /test none contents2
   10.35 +write /test contents2
   10.36  setid 0
   10.37  expect contents2
   10.38  read /test
   10.39 @@ -47,7 +47,7 @@ expect 0 READ/WRITE
   10.40  getperm /test
   10.41  expect contents2
   10.42  read /test
   10.43 -write /test none contents3
   10.44 +write /test contents3
   10.45  expect contents3
   10.46  read /test
   10.47  
   10.48 @@ -59,7 +59,7 @@ expect 1 NONE
   10.49  getperm /test
   10.50  expect contents3
   10.51  read /test
   10.52 -write /test none contents4
   10.53 +write /test contents4
   10.54  
   10.55  # User 2 can do nothing.
   10.56  setid 2
   10.57 @@ -70,7 +70,7 @@ getperm /test
   10.58  expect read failed: Permission denied
   10.59  read /test
   10.60  expect write failed: Permission denied
   10.61 -write /test none contents4
   10.62 +write /test contents4
   10.63  
   10.64  # Tools can always access things.
   10.65  setid 0
   10.66 @@ -78,4 +78,4 @@ expect 1 NONE
   10.67  getperm /test
   10.68  expect contents4
   10.69  read /test
   10.70 -write /test none contents5
   10.71 +write /test contents5
    11.1 --- a/tools/xenstore/testsuite/06dirpermissions.test	Mon Sep 19 14:25:29 2005 +0000
    11.2 +++ b/tools/xenstore/testsuite/06dirpermissions.test	Mon Sep 19 14:34:30 2005 +0000
    11.3 @@ -11,7 +11,7 @@ expect 0 READ
    11.4  getperm /dir
    11.5  dir /dir
    11.6  expect write failed: Permission denied
    11.7 -write /dir/test create contents2
    11.8 +write /dir/test contents2
    11.9  
   11.10  # Remove everyone's read access to directoy.
   11.11  setid 0
   11.12 @@ -22,7 +22,7 @@ dir /dir
   11.13  expect read failed: Permission denied
   11.14  read /dir/test create contents2
   11.15  expect write failed: Permission denied
   11.16 -write /dir/test create contents2
   11.17 +write /dir/test contents2
   11.18  
   11.19  # Grant everyone write access to directory.
   11.20  setid 0
   11.21 @@ -32,7 +32,7 @@ expect getperm failed: Permission denied
   11.22  getperm /dir
   11.23  expect dir failed: Permission denied
   11.24  dir /dir
   11.25 -write /dir/test create contents
   11.26 +write /dir/test contents
   11.27  setid 0
   11.28  expect 1 WRITE
   11.29  getperm /dir/test
   11.30 @@ -47,7 +47,7 @@ expect 0 READ/WRITE
   11.31  getperm /dir
   11.32  expect test
   11.33  dir /dir
   11.34 -write /dir/test2 create contents
   11.35 +write /dir/test2 contents
   11.36  expect contents
   11.37  read /dir/test2
   11.38  setperm /dir/test2 1 NONE
   11.39 @@ -60,7 +60,7 @@ getperm /dir
   11.40  expect test
   11.41  expect test2
   11.42  dir /dir
   11.43 -write /dir/test3 create contents
   11.44 +write /dir/test3 contents
   11.45  
   11.46  # User 2 can do nothing.  Can't even tell if file exists.
   11.47  setid 2
   11.48 @@ -79,17 +79,9 @@ read /dir/test3
   11.49  expect read failed: Permission denied
   11.50  read /dir/test4
   11.51  expect write failed: Permission denied
   11.52 -write /dir/test none contents
   11.53 -expect write failed: Permission denied
   11.54 -write /dir/test create contents
   11.55 -expect write failed: Permission denied
   11.56 -write /dir/test excl contents
   11.57 +write /dir/test contents
   11.58  expect write failed: Permission denied
   11.59 -write /dir/test4 none contents
   11.60 -expect write failed: Permission denied
   11.61 -write /dir/test4 create contents
   11.62 -expect write failed: Permission denied
   11.63 -write /dir/test4 excl contents
   11.64 +write /dir/test4 contents
   11.65  
   11.66  # Tools can always access things.
   11.67  setid 0
   11.68 @@ -99,13 +91,13 @@ expect test
   11.69  expect test2
   11.70  expect test3
   11.71  dir /dir
   11.72 -write /dir/test4 create contents
   11.73 +write /dir/test4 contents
   11.74  
   11.75  # Inherited by child.
   11.76  mkdir /dir/subdir
   11.77  expect 1 NONE
   11.78  getperm /dir/subdir
   11.79 -write /dir/subfile excl contents
   11.80 +write /dir/subfile contents
   11.81  expect 1 NONE
   11.82  getperm /dir/subfile
   11.83  
   11.84 @@ -114,12 +106,12 @@ setperm /dir/subdir 2 READ/WRITE
   11.85  expect 2 READ/WRITE
   11.86  getperm /dir/subdir
   11.87  setid 3
   11.88 -write /dir/subdir/subfile excl contents
   11.89 +write /dir/subdir/subfile contents
   11.90  expect 3 READ/WRITE
   11.91  getperm /dir/subdir/subfile
   11.92  
   11.93  # Inheritence works through multiple directories, too.
   11.94 -write /dir/subdir/1/2/3/4 excl contents
   11.95 +write /dir/subdir/1/2/3/4 contents
   11.96  expect 3 READ/WRITE
   11.97  getperm /dir/subdir/1/2/3/4
   11.98  mkdir /dir/subdir/a/b/c/d
    12.1 --- a/tools/xenstore/testsuite/07watch.test	Mon Sep 19 14:25:29 2005 +0000
    12.2 +++ b/tools/xenstore/testsuite/07watch.test	Mon Sep 19 14:34:30 2005 +0000
    12.3 @@ -1,8 +1,8 @@
    12.4  # Watch something, write to it, check watch has fired.
    12.5 -write /test create contents
    12.6 +write /test contents
    12.7  
    12.8  1 watch /test token
    12.9 -2 write /test create contents2
   12.10 +2 write /test contents2
   12.11  expect 1:/test:token
   12.12  1 waitwatch
   12.13  1 ackwatch token
   12.14 @@ -44,7 +44,7 @@ 2 close
   12.15  
   12.16  # ignore watches while doing commands, should work.
   12.17  watch /dir token
   12.18 -1 write /dir/test create contents
   12.19 +1 write /dir/test contents
   12.20  expect contents
   12.21  read /dir/test
   12.22  expect /dir/test:token
   12.23 @@ -56,7 +56,7 @@ close
   12.24  1 watch /dir token1
   12.25  3 watch /dir token3
   12.26  2 watch /dir token2
   12.27 -write /dir/test create contents
   12.28 +write /dir/test contents
   12.29  expect 3:/dir/test:token3
   12.30  3 waitwatch
   12.31  3 ackwatch token3
   12.32 @@ -73,7 +73,7 @@ 3 close
   12.33  # If one dies (without acking), the other should still get ack.
   12.34  1 watch /dir token1
   12.35  2 watch /dir token2
   12.36 -write /dir/test create contents
   12.37 +write /dir/test contents
   12.38  expect 2:/dir/test:token2
   12.39  2 waitwatch
   12.40  2 close
   12.41 @@ -85,7 +85,7 @@ 1 close
   12.42  # If one dies (without reading at all), the other should still get ack.
   12.43  1 watch /dir token1
   12.44  2 watch /dir token2
   12.45 -write /dir/test create contents
   12.46 +write /dir/test contents
   12.47  2 close
   12.48  expect 1:/dir/test:token1
   12.49  1 waitwatch
   12.50 @@ -97,7 +97,7 @@ 2 close
   12.51  1 watch /dir token1
   12.52  1 unwatch /dir token1
   12.53  1 watch /dir token2
   12.54 -2 write /dir/test2 create contents
   12.55 +2 write /dir/test2 contents
   12.56  expect 1:/dir/test2:token2
   12.57  1 waitwatch
   12.58  1 unwatch /dir token2
   12.59 @@ -107,7 +107,7 @@ 2 close
   12.60  # unwatch while watch pending.  Other watcher still gets the event.
   12.61  1 watch /dir token1
   12.62  2 watch /dir token2
   12.63 -write /dir/test create contents
   12.64 +write /dir/test contents
   12.65  2 unwatch /dir token2
   12.66  expect 1:/dir/test:token1
   12.67  1 waitwatch
   12.68 @@ -117,17 +117,17 @@ 2 close
   12.69  
   12.70  # unwatch while watch pending.  Should clear this so we get next event.
   12.71  1 watch /dir token1
   12.72 -write /dir/test create contents
   12.73 +write /dir/test contents
   12.74  1 unwatch /dir token1
   12.75  1 watch /dir/test token2
   12.76 -write /dir/test none contents2
   12.77 +write /dir/test contents2
   12.78  expect 1:/dir/test:token2
   12.79  1 waitwatch
   12.80  1 ackwatch token2
   12.81  
   12.82  # check we only get notified once.
   12.83  1 watch /test token
   12.84 -2 write /test create contents2
   12.85 +2 write /test contents2
   12.86  expect 1:/test:token
   12.87  1 waitwatch
   12.88  1 ackwatch token
   12.89 @@ -137,9 +137,9 @@ 1 close
   12.90  
   12.91  # watches are queued in order.
   12.92  1 watch / token
   12.93 -2 write /test1 create contents
   12.94 -2 write /test2 create contents
   12.95 -2 write /test3 create contents
   12.96 +2 write /test1 contents
   12.97 +2 write /test2 contents
   12.98 +2 write /test3 contents
   12.99  expect 1:/test1:token
  12.100  1 waitwatch
  12.101  1 ackwatch token
  12.102 @@ -153,8 +153,8 @@ 1 close
  12.103  
  12.104  # Creation of subpaths should be covered correctly.
  12.105  1 watch / token
  12.106 -2 write /test/subnode create contents2
  12.107 -2 write /test/subnode/subnode create contents2
  12.108 +2 write /test/subnode contents2
  12.109 +2 write /test/subnode/subnode contents2
  12.110  expect 1:/test/subnode:token
  12.111  1 waitwatch
  12.112  1 ackwatch token
  12.113 @@ -167,7 +167,7 @@ 1 close
  12.114  
  12.115  # Watch event must have happened before we registered interest.
  12.116  1 watch / token
  12.117 -2 write /test/subnode create contents2
  12.118 +2 write /test/subnode contents2
  12.119  1 watch / token2 0
  12.120  expect 1:/test/subnode:token
  12.121  1 waitwatch
  12.122 @@ -185,7 +185,7 @@ 1 ackwatch token
  12.123  
  12.124  # Watch should not double-send after we ack, even if we did something in between.
  12.125  1 watch /test2 token
  12.126 -2 write /test2/foo create contents2
  12.127 +2 write /test2/foo contents2
  12.128  expect 1:/test2/foo:token
  12.129  1 waitwatch
  12.130  expect 1:contents2
    13.1 --- a/tools/xenstore/testsuite/08transaction.slowtest	Mon Sep 19 14:25:29 2005 +0000
    13.2 +++ b/tools/xenstore/testsuite/08transaction.slowtest	Mon Sep 19 14:34:30 2005 +0000
    13.3 @@ -1,7 +1,7 @@
    13.4  # Test transaction timeouts.  Take a second each.
    13.5  
    13.6  mkdir /test
    13.7 -write /test/entry1 create contents
    13.8 +write /test/entry1 contents
    13.9  
   13.10  # Transactions can take as long as the want...
   13.11  start /test
    14.1 --- a/tools/xenstore/testsuite/08transaction.test	Mon Sep 19 14:25:29 2005 +0000
    14.2 +++ b/tools/xenstore/testsuite/08transaction.test	Mon Sep 19 14:34:30 2005 +0000
    14.3 @@ -4,7 +4,7 @@ mkdir /test
    14.4  
    14.5  # Simple transaction: create a file inside transaction.
    14.6  1 start /test
    14.7 -1 write /test/entry1 create contents
    14.8 +1 write /test/entry1 contents
    14.9  2 dir /test
   14.10  expect 1:entry1
   14.11  1 dir /test
   14.12 @@ -16,14 +16,14 @@ rm /test/entry1
   14.13  
   14.14  # Create a file and abort transaction.
   14.15  1 start /test
   14.16 -1 write /test/entry1 create contents
   14.17 +1 write /test/entry1 contents
   14.18  2 dir /test
   14.19  expect 1:entry1
   14.20  1 dir /test
   14.21  1 abort
   14.22  2 dir /test
   14.23  
   14.24 -write /test/entry1 create contents
   14.25 +write /test/entry1 contents
   14.26  # Delete in transaction, commit
   14.27  1 start /test
   14.28  1 rm /test/entry1
   14.29 @@ -34,7 +34,7 @@ 1 commit
   14.30  2 dir /test
   14.31  
   14.32  # Delete in transaction, abort.
   14.33 -write /test/entry1 create contents
   14.34 +write /test/entry1 contents
   14.35  1 start /test
   14.36  1 rm /test/entry1
   14.37  expect 2:entry1
   14.38 @@ -84,8 +84,8 @@ 1 close
   14.39  # Multiple events from single transaction don't trigger assert
   14.40  1 watch /test token
   14.41  2 start /test
   14.42 -2 write /test/1 create contents
   14.43 -2 write /test/2 create contents
   14.44 +2 write /test/1 contents
   14.45 +2 write /test/2 contents
   14.46  2 commit
   14.47  expect 1:/test/1:token
   14.48  1 waitwatch
    15.1 --- a/tools/xenstore/testsuite/09domain.test	Mon Sep 19 14:25:29 2005 +0000
    15.2 +++ b/tools/xenstore/testsuite/09domain.test	Mon Sep 19 14:34:30 2005 +0000
    15.3 @@ -3,7 +3,7 @@
    15.4  # Create a domain, write an entry.
    15.5  expect handle is 1
    15.6  introduce 1 100 7 /my/home
    15.7 -1 write /entry1 create contents
    15.8 +1 write /entry1 contents
    15.9  expect entry1
   15.10  expect tool
   15.11  dir /
    16.1 --- a/tools/xenstore/testsuite/10domain-homedir.test	Mon Sep 19 14:25:29 2005 +0000
    16.2 +++ b/tools/xenstore/testsuite/10domain-homedir.test	Mon Sep 19 14:34:30 2005 +0000
    16.3 @@ -4,7 +4,7 @@
    16.4  mkdir /home
    16.5  expect handle is 1
    16.6  introduce 1 100 7 /home
    16.7 -1 write entry1 create contents
    16.8 +1 write entry1 contents
    16.9  expect contents
   16.10  read /home/entry1
   16.11  expect entry1
   16.12 @@ -13,7 +13,7 @@ dir /home
   16.13  # Place a watch using a relative path: expect relative answer.
   16.14  1 mkdir foo
   16.15  1 watch foo token
   16.16 -write /home/foo/bar create contents
   16.17 +write /home/foo/bar contents
   16.18  expect 1:foo/bar:token
   16.19  1 waitwatch
   16.20  1 ackwatch token
    17.1 --- a/tools/xenstore/testsuite/11domain-watch.test	Mon Sep 19 14:25:29 2005 +0000
    17.2 +++ b/tools/xenstore/testsuite/11domain-watch.test	Mon Sep 19 14:34:30 2005 +0000
    17.3 @@ -1,13 +1,13 @@
    17.4  # Test watching from a domain.
    17.5  
    17.6  # Watch something, write to it, check watch has fired.
    17.7 -write /test create contents
    17.8 +write /test contents
    17.9  mkdir /dir
   17.10  
   17.11  expect handle is 1
   17.12  introduce 1 100 7 /my/home
   17.13  1 watch /test token
   17.14 -write /test create contents2
   17.15 +write /test contents2
   17.16  expect 1:/test:token
   17.17  1 waitwatch
   17.18  1 ackwatch token
   17.19 @@ -19,10 +19,10 @@ 1 close
   17.20  expect handle is 1
   17.21  introduce 1 100 7 /my/home
   17.22  1 watch /dir token
   17.23 -write /dir/test create contents
   17.24 -1 write /dir/test2 create contents2
   17.25 -1 write /dir/test3 create contents3
   17.26 -1 write /dir/test4 create contents4
   17.27 +write /dir/test contents
   17.28 +1 write /dir/test2 contents2
   17.29 +1 write /dir/test3 contents3
   17.30 +1 write /dir/test4 contents4
   17.31  expect 1:/dir/test:token
   17.32  1 waitwatch
   17.33  1 ackwatch token
   17.34 @@ -35,7 +35,7 @@ introduce 1 100 7 /my/home
   17.35  1 watch /dir token1
   17.36  1 unwatch /dir token1
   17.37  1 watch /dir token2
   17.38 -write /dir/test2 create contents
   17.39 +write /dir/test2 contents
   17.40  expect 1:/dir/test2:token2
   17.41  1 waitwatch
   17.42  1 unwatch /dir token2
   17.43 @@ -46,7 +46,7 @@ 1 close
   17.44  expect handle is 1
   17.45  introduce 1 100 7 /my/home
   17.46  1 watch /dir token1
   17.47 -write /dir/test2 create contents
   17.48 +write /dir/test2 contents
   17.49  1 unwatch /dir token1
   17.50  release 1
   17.51  1 close
    18.1 --- a/tools/xenstore/testsuite/12readonly.test	Mon Sep 19 14:25:29 2005 +0000
    18.2 +++ b/tools/xenstore/testsuite/12readonly.test	Mon Sep 19 14:34:30 2005 +0000
    18.3 @@ -1,6 +1,6 @@
    18.4  # Test that read only connection can't alter store.
    18.5  
    18.6 -write /test create contents
    18.7 +write /test contents
    18.8  
    18.9  readonly
   18.10  expect test
   18.11 @@ -20,9 +20,9 @@ abort
   18.12  
   18.13  # These don't work
   18.14  expect write failed: Read-only file system
   18.15 -write /test2 create contents
   18.16 +write /test2 contents
   18.17  expect write failed: Read-only file system
   18.18 -write /test create contents
   18.19 +write /test contents
   18.20  expect setperm failed: Read-only file system
   18.21  setperm /test 100 NONE
   18.22  expect setperm failed: Read-only file system
   18.23 @@ -35,7 +35,7 @@ introduce 1 100 7 /home
   18.24  # Check that watches work like normal.
   18.25  watch / token
   18.26  1 readwrite
   18.27 -1 write /test create contents
   18.28 +1 write /test contents
   18.29  expect /test:token
   18.30  waitwatch
   18.31  ackwatch token
    19.1 --- a/tools/xenstore/testsuite/13watch-ack.test	Mon Sep 19 14:25:29 2005 +0000
    19.2 +++ b/tools/xenstore/testsuite/13watch-ack.test	Mon Sep 19 14:34:30 2005 +0000
    19.3 @@ -13,10 +13,10 @@ mkdir /test/3
    19.4  1 watch /test/1 token1
    19.5  1 watch /test/2 token2
    19.6  1 watch /test/3 token3
    19.7 -2 write /test/2 create contents2
    19.8 +2 write /test/2 contents2
    19.9  expect 1:/test/2:token2
   19.10  1 waitwatch
   19.11 -3 write /test/1 create contents1
   19.12 -4 write /test/3 create contents3
   19.13 +3 write /test/1 contents1
   19.14 +4 write /test/3 contents3
   19.15  1 ackwatch token2
   19.16  1 close
    20.1 --- a/tools/xenstore/testsuite/14complexperms.test	Mon Sep 19 14:25:29 2005 +0000
    20.2 +++ b/tools/xenstore/testsuite/14complexperms.test	Mon Sep 19 14:34:30 2005 +0000
    20.3 @@ -12,13 +12,7 @@ dir /dir/file
    20.4  expect *Permission denied
    20.5  read /dir/file 
    20.6  expect *Permission denied
    20.7 -write /dir/file none value 
    20.8 -expect *Permission denied
    20.9 -write /dir/file create value 
   20.10 -expect *Permission denied
   20.11 -write /dir/file excl value 
   20.12 -expect write failed: Invalid argument
   20.13 -write /dir/file crap value 
   20.14 +write /dir/file value 
   20.15  expect *Permission denied
   20.16  mkdir /dir/file 
   20.17  expect *Permission denied
   20.18 @@ -30,7 +24,7 @@ getperm /dir/file
   20.19  expect *Permission denied
   20.20  setperm /dir/file 0 NONE 
   20.21  watch /dir/file token 
   20.22 -1 write /dir/file create contents
   20.23 +1 write /dir/file contents
   20.24  1 rm /dir/file
   20.25  expect waitwatch failed: Connection timed out
   20.26  waitwatch
   20.27 @@ -50,7 +44,7 @@ introduce 2 100 7 /dir/file
   20.28  
   20.29  # Now it exists
   20.30  setid 0
   20.31 -write /dir/file create contents
   20.32 +write /dir/file contents
   20.33  
   20.34  setid 1
   20.35  expect *Permission denied
   20.36 @@ -58,13 +52,7 @@ dir /dir/file
   20.37  expect *Permission denied
   20.38  read /dir/file 
   20.39  expect *Permission denied
   20.40 -write /dir/file none value 
   20.41 -expect *Permission denied
   20.42 -write /dir/file create value 
   20.43 -expect *Permission denied
   20.44 -write /dir/file excl value 
   20.45 -expect write failed: Invalid argument
   20.46 -write /dir/file crap value 
   20.47 +write /dir/file value 
   20.48  expect *Permission denied
   20.49  mkdir /dir/file 
   20.50  expect *Permission denied
   20.51 @@ -76,7 +64,7 @@ getperm /dir/file
   20.52  expect *Permission denied
   20.53  setperm /dir/file 0 NONE 
   20.54  watch /dir/file token 
   20.55 -1 write /dir/file create contents
   20.56 +1 write /dir/file contents
   20.57  1 rm /dir/file
   20.58  expect waitwatch failed: Connection timed out
   20.59  waitwatch
    21.1 --- a/tools/xenstore/testsuite/15nowait.test	Mon Sep 19 14:25:29 2005 +0000
    21.2 +++ b/tools/xenstore/testsuite/15nowait.test	Mon Sep 19 14:34:30 2005 +0000
    21.3 @@ -1,10 +1,10 @@
    21.4  # If we don't wait for an ack, we can crash daemon as it never expects to be
    21.5  # sending out two replies on top of each other.
    21.6 -noackwrite /1 create 1
    21.7 -noackwrite /2 create 2
    21.8 -noackwrite /3 create 3
    21.9 -noackwrite /4 create 4
   21.10 -noackwrite /5 create 5
   21.11 +noackwrite /1 1
   21.12 +noackwrite /2 2
   21.13 +noackwrite /3 3
   21.14 +noackwrite /4 4
   21.15 +noackwrite /5 5
   21.16  readack
   21.17  readack
   21.18  readack
   21.19 @@ -13,11 +13,11 @@ readack
   21.20  
   21.21  expect handle is 1
   21.22  introduce 1 100 7 /my/home
   21.23 -1 noackwrite /1 create 1
   21.24 -1 noackwrite /2 create 2
   21.25 -1 noackwrite /3 create 3
   21.26 -1 noackwrite /4 create 4
   21.27 -1 noackwrite /5 create 5
   21.28 +1 noackwrite /1 1
   21.29 +1 noackwrite /2 2
   21.30 +1 noackwrite /3 3
   21.31 +1 noackwrite /4 4
   21.32 +1 noackwrite /5 5
   21.33  1 readack
   21.34  1 readack
   21.35  1 readack
    22.1 --- a/tools/xenstore/testsuite/16block-watch-crash.test	Mon Sep 19 14:25:29 2005 +0000
    22.2 +++ b/tools/xenstore/testsuite/16block-watch-crash.test	Mon Sep 19 14:34:30 2005 +0000
    22.3 @@ -4,8 +4,8 @@ mkdir /test
    22.4  watch /test token
    22.5  1 start /test
    22.6  # This will block on above
    22.7 -noackwrite /test/entry create contents
    22.8 -1 write /test/entry2 create contents
    22.9 +noackwrite /test/entry contents
   22.10 +1 write /test/entry2 contents
   22.11  1 commit
   22.12  readack
   22.13  expect /test/entry2:token
    23.1 --- a/tools/xenstore/xenstored_core.c	Mon Sep 19 14:25:29 2005 +0000
    23.2 +++ b/tools/xenstore/xenstored_core.c	Mon Sep 19 14:34:30 2005 +0000
    23.3 @@ -968,14 +968,12 @@ static bool node_exists(struct connectio
    23.4  	return lstat(node_dir(conn->transaction, node), &st) == 0;
    23.5  }
    23.6  
    23.7 -/* path, flags, data... */
    23.8 +/* path, data... */
    23.9  static void do_write(struct connection *conn, struct buffered_data *in)
   23.10  {
   23.11  	unsigned int offset, datalen;
   23.12 -	char *vec[2];
   23.13 +	char *vec[1] = { NULL }; /* gcc4 + -W + -Werror fucks code. */
   23.14  	char *node, *tmppath;
   23.15 -	enum xs_perm_type mode;
   23.16 -	struct stat st;
   23.17  
   23.18  	/* Extra "strings" can be created by binary data. */
   23.19  	if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) {
   23.20 @@ -992,26 +990,15 @@ static void do_write(struct connection *
   23.21  	if (transaction_block(conn, node))
   23.22  		return;
   23.23  
   23.24 -	offset = strlen(vec[0]) + strlen(vec[1]) + 2;
   23.25 +	offset = strlen(vec[0]) + 1;
   23.26  	datalen = in->used - offset;
   23.27  
   23.28 -	if (streq(vec[1], XS_WRITE_NONE))
   23.29 -		mode = XS_PERM_WRITE;
   23.30 -	else if (streq(vec[1], XS_WRITE_CREATE))
   23.31 -		mode = XS_PERM_WRITE|XS_PERM_ENOENT_OK;
   23.32 -	else if (streq(vec[1], XS_WRITE_CREATE_EXCL))
   23.33 -		mode = XS_PERM_WRITE|XS_PERM_ENOENT_OK;
   23.34 -	else {
   23.35 -		send_error(conn, EINVAL);
   23.36 -		return;
   23.37 -	}
   23.38 -
   23.39 -	if (!check_node_perms(conn, node, mode)) {
   23.40 +	if (!check_node_perms(conn, node, XS_PERM_WRITE|XS_PERM_ENOENT_OK)) {
   23.41  		send_error(conn, errno);
   23.42  		return;
   23.43  	}
   23.44  
   23.45 -	if (lstat(node_dir(conn->transaction, node), &st) != 0) {
   23.46 +	if (!node_exists(conn, node)) {
   23.47  		char *dir;
   23.48  
   23.49  		/* Does not exist... */
   23.50 @@ -1020,12 +1007,6 @@ static void do_write(struct connection *
   23.51  			return;
   23.52  		}
   23.53  
   23.54 -		/* Not going to create it? */
   23.55 -		if (streq(vec[1], XS_WRITE_NONE)) {
   23.56 -			send_error(conn, ENOENT);
   23.57 -			return;
   23.58 -		}
   23.59 -
   23.60  		dir = tempdir(conn, node, in->buffer + offset, datalen);
   23.61  		if (!dir || !commit_dir(dir)) {
   23.62  			send_error(conn, errno);
   23.63 @@ -1034,11 +1015,6 @@ static void do_write(struct connection *
   23.64  		
   23.65  	} else {
   23.66  		/* Exists... */
   23.67 -		if (streq(vec[1], XS_WRITE_CREATE_EXCL)) {
   23.68 -			send_error(conn, EEXIST);
   23.69 -			return;
   23.70 -		}
   23.71 -
   23.72  		tmppath = tempfile(node_datafile(conn->transaction, node),
   23.73  				   in->buffer + offset, datalen);
   23.74  		if (!tmppath) {
    24.1 --- a/tools/xenstore/xs.c	Mon Sep 19 14:25:29 2005 +0000
    24.2 +++ b/tools/xenstore/xs.c	Mon Sep 19 14:34:30 2005 +0000
    24.3 @@ -326,32 +326,17 @@ void *xs_read(struct xs_handle *h, const
    24.4  }
    24.5  
    24.6  /* Write the value of a single file.
    24.7 - * Returns false on failure.  createflags can be 0, O_CREAT, or O_CREAT|O_EXCL.
    24.8 + * Returns false on failure.
    24.9   */
   24.10  bool xs_write(struct xs_handle *h, const char *path,
   24.11 -	      const void *data, unsigned int len, int createflags)
   24.12 +	      const void *data, unsigned int len)
   24.13  {
   24.14 -	const char *flags;
   24.15 -	struct iovec iovec[3];
   24.16 -
   24.17 -	/* Format: Flags (as string), path, data. */
   24.18 -	if (createflags == 0)
   24.19 -		flags = XS_WRITE_NONE;
   24.20 -	else if (createflags == O_CREAT)
   24.21 -		flags = XS_WRITE_CREATE;
   24.22 -	else if (createflags == (O_CREAT|O_EXCL))
   24.23 -		flags = XS_WRITE_CREATE_EXCL;
   24.24 -	else {
   24.25 -		errno = EINVAL;
   24.26 -		return false;
   24.27 -	}
   24.28 +	struct iovec iovec[2];
   24.29  
   24.30  	iovec[0].iov_base = (void *)path;
   24.31  	iovec[0].iov_len = strlen(path) + 1;
   24.32 -	iovec[1].iov_base = (void *)flags;
   24.33 -	iovec[1].iov_len = strlen(flags) + 1;
   24.34 -	iovec[2].iov_base = (void *)data;
   24.35 -	iovec[2].iov_len = len;
   24.36 +	iovec[1].iov_base = (void *)data;
   24.37 +	iovec[1].iov_len = len;
   24.38  
   24.39  	return xs_bool(xs_talkv(h, XS_WRITE, iovec, ARRAY_SIZE(iovec), NULL));
   24.40  }
    25.1 --- a/tools/xenstore/xs.h	Mon Sep 19 14:25:29 2005 +0000
    25.2 +++ b/tools/xenstore/xs.h	Mon Sep 19 14:34:30 2005 +0000
    25.3 @@ -53,10 +53,10 @@ char **xs_directory(struct xs_handle *h,
    25.4  void *xs_read(struct xs_handle *h, const char *path, unsigned int *len);
    25.5  
    25.6  /* Write the value of a single file.
    25.7 - * Returns false on failure.  createflags can be 0, O_CREAT, or O_CREAT|O_EXCL.
    25.8 + * Returns false on failure.
    25.9   */
   25.10  bool xs_write(struct xs_handle *h, const char *path, const void *data,
   25.11 -	      unsigned int len, int createflags);
   25.12 +	      unsigned int len);
   25.13  
   25.14  /* Create a new directory.
   25.15   * Returns false on failure, or success if it already exists.
    26.1 --- a/tools/xenstore/xs_crashme.c	Mon Sep 19 14:25:29 2005 +0000
    26.2 +++ b/tools/xenstore/xs_crashme.c	Mon Sep 19 14:34:30 2005 +0000
    26.3 @@ -267,17 +267,12 @@ static void do_next_op(struct xs_handle 
    26.4  		free(xs_read(h, name, &num));
    26.5  		break;
    26.6  	case 2: {
    26.7 -		int flags = random_flags(&state);
    26.8  		char *contents = talloc_asprintf(NULL, "%i",
    26.9  						 get_randomness(&state));
   26.10  		unsigned int len = get_randomness(&state)%(strlen(contents)+1);
   26.11  		if (verbose)
   26.12 -			printf("WRITE %s %s %.*s\n", name,
   26.13 -			       flags == O_CREAT ? "O_CREAT" 
   26.14 -			       : flags == (O_CREAT|O_EXCL) ? "O_CREAT|O_EXCL"
   26.15 -			       : flags == 0 ? "0" : "CRAPFLAGS",
   26.16 -			       len, contents);
   26.17 -		xs_write(h, name, contents, len, flags);
   26.18 +			printf("WRITE %s %.*s\n", name, len, contents);
   26.19 +		xs_write(h, name, contents, len);
   26.20  		break;
   26.21  	}
   26.22  	case 3:
    27.1 --- a/tools/xenstore/xs_random.c	Mon Sep 19 14:25:29 2005 +0000
    27.2 +++ b/tools/xenstore/xs_random.c	Mon Sep 19 14:34:30 2005 +0000
    27.3 @@ -26,7 +26,7 @@ struct ops
    27.4  	void *(*read)(void *h, const char *path, unsigned int *len);
    27.5  
    27.6  	bool (*write)(void *h, const char *path, const void *data,
    27.7 -		      unsigned int len, int createflags);
    27.8 +		      unsigned int len);
    27.9  
   27.10  	bool (*mkdir)(void *h, const char *path);
   27.11  
   27.12 @@ -333,40 +333,18 @@ static void make_dirs(const char *filena
   27.13  
   27.14  static bool file_write(struct file_ops_info *info,
   27.15  		       const char *path, const void *data,
   27.16 -		       unsigned int len, int createflags)
   27.17 +		       unsigned int len)
   27.18  {
   27.19  	char *filename = filename_to_data(path_to_name(info, path));
   27.20  	int fd;
   27.21  
   27.22 -	/* Kernel isn't strict, but library is. */
   27.23 -	if (createflags & ~(O_CREAT|O_EXCL)) {
   27.24 -		errno = EINVAL;
   27.25 -		return false;
   27.26 -	}
   27.27 -
   27.28  	if (!write_ok(info, path))
   27.29  		return false;
   27.30  
   27.31 -	/* We regard it as existing if dir exists. */
   27.32 -	if (strends(filename, ".DATA")) {
   27.33 -		if (!createflags)
   27.34 -			createflags = O_CREAT;
   27.35 -		if (createflags & O_EXCL) {
   27.36 -			errno = EEXIST;
   27.37 -			return false;
   27.38 -		}
   27.39 -	}
   27.40 -
   27.41 -	if (createflags & O_CREAT)
   27.42 -		make_dirs(parent_filename(filename));
   27.43 -
   27.44 -	fd = open(filename, createflags|O_TRUNC|O_WRONLY, 0600);
   27.45 -	if (fd < 0) {
   27.46 -		/* FIXME: Another hack. */
   27.47 -		if (!(createflags & O_CREAT) && errno == EISDIR)
   27.48 -			errno = EEXIST;
   27.49 +	make_dirs(parent_filename(filename));
   27.50 +	fd = open(filename, O_CREAT|O_TRUNC|O_WRONLY, 0600);
   27.51 +	if (fd < 0)
   27.52  		return false;
   27.53 -	}
   27.54  
   27.55  	if (write(fd, data, len) != (int)len)
   27.56  		barf_perror("Bad write to %s", filename);
   27.57 @@ -846,20 +824,6 @@ static char *linearize_perms(struct xs_p
   27.58  	return ret;
   27.59  }
   27.60  
   27.61 -static int random_flags(int *state)
   27.62 -{
   27.63 -	switch (get_randomness(state) % 4) {
   27.64 -	case 0:
   27.65 -		return 0;
   27.66 -	case 1:
   27.67 -		return O_CREAT;
   27.68 -	case 2:
   27.69 -		return O_CREAT|O_EXCL;
   27.70 -	default:
   27.71 -		return get_randomness(state);
   27.72 -	}
   27.73 -}
   27.74 -
   27.75  /* Do the next operation, return the results. */
   27.76  static char *do_next_op(struct ops *ops, void *h, int state, bool verbose)
   27.77  {
   27.78 @@ -883,18 +847,12 @@ static char *do_next_op(struct ops *ops,
   27.79  		ret = linearize_read(ops->read(h, name, &num), &num);
   27.80  		break;
   27.81  	case 2: {
   27.82 -		int flags = random_flags(&state);
   27.83  		char *contents = talloc_asprintf(NULL, "%i",
   27.84  						 get_randomness(&state));
   27.85  		unsigned int len = get_randomness(&state)%(strlen(contents)+1);
   27.86  		if (verbose)
   27.87 -			printf("WRITE %s %s %.*s\n", name,
   27.88 -			       flags == O_CREAT ? "O_CREAT" 
   27.89 -			       : flags == (O_CREAT|O_EXCL) ? "O_CREAT|O_EXCL"
   27.90 -			       : flags == 0 ? "0" : "CRAPFLAGS",
   27.91 -			       len, contents);
   27.92 -		ret = bool_to_errstring(ops->write(h, name, contents, len,
   27.93 -						   flags));
   27.94 +			printf("WRITE %s %.*s\n", name, len, contents);
   27.95 +		ret = bool_to_errstring(ops->write(h, name, contents, len));
   27.96  		talloc_steal(ret, contents);
   27.97  		break;
   27.98  	}
    28.1 --- a/tools/xenstore/xs_stress.c	Mon Sep 19 14:25:29 2005 +0000
    28.2 +++ b/tools/xenstore/xs_stress.c	Mon Sep 19 14:34:30 2005 +0000
    28.3 @@ -61,7 +61,7 @@ static void work(unsigned int cycles, un
    28.4  			barf_perror("%i: can't read %s iter %i",
    28.5  				    childnum, file, i);
    28.6  		sprintf(tmp, "%i", atoi(contents) + 1);
    28.7 -		if (!xs_write(h, file, tmp, strlen(tmp)+1, 0))
    28.8 +		if (!xs_write(h, file, tmp, strlen(tmp)+1))
    28.9  			barf_perror("%i: can't write %s iter %i",
   28.10  				    childnum, file, i);
   28.11  
   28.12 @@ -91,7 +91,7 @@ static void create_dirs(struct xs_handle
   28.13  
   28.14  	if (togo == 0) {
   28.15  		sprintf(filename, "%s/count", base);
   28.16 -		if (!xs_write(h, filename, "0", 2, O_EXCL|O_CREAT))
   28.17 +		if (!xs_write(h, filename, "0", 1))
   28.18  			barf_perror("Writing to %s", filename);
   28.19  		return;
   28.20  	}
    29.1 --- a/tools/xenstore/xs_test.c	Mon Sep 19 14:25:29 2005 +0000
    29.2 +++ b/tools/xenstore/xs_test.c	Mon Sep 19 14:34:30 2005 +0000
    29.3 @@ -192,7 +192,7 @@ static void __attribute__((noreturn)) us
    29.4  	     "Reads commands from stdin, one per line:"
    29.5  	     "  dir <path>\n"
    29.6  	     "  read <path>\n"
    29.7 -	     "  write <path> <flags> <value>...\n"
    29.8 +	     "  write <path> <value>...\n"
    29.9  	     "  setid <id>\n"
   29.10  	     "  mkdir <path>\n"
   29.11  	     "  rm <path>\n"
   29.12 @@ -213,7 +213,7 @@ static void __attribute__((noreturn)) us
   29.13  	     "  notimeout\n"
   29.14  	     "  readonly\n"
   29.15  	     "  readwrite\n"
   29.16 -	     "  noackwrite <path> <flags> <value>...\n"
   29.17 +	     "  noackwrite <path> <value>...\n"
   29.18  	     "  readack\n"
   29.19  	     "  dump\n");
   29.20  }
   29.21 @@ -348,48 +348,23 @@ static void do_read(unsigned int handle,
   29.22  		output("%.*s\n", len, value);
   29.23  }
   29.24  
   29.25 -static void do_write(unsigned int handle, char *path, char *flags, char *data)
   29.26 +static void do_write(unsigned int handle, char *path, char *data)
   29.27  {
   29.28 -	int f;
   29.29 -
   29.30 -	if (streq(flags, "none"))
   29.31 -		f = 0;
   29.32 -	else if (streq(flags, "create"))
   29.33 -		f = O_CREAT;
   29.34 -	else if (streq(flags, "excl"))
   29.35 -		f = O_CREAT | O_EXCL;
   29.36 -	else if (streq(flags, "crap"))
   29.37 -		f = 100;
   29.38 -	else
   29.39 -		barf("write flags 'none', 'create' or 'excl' only");
   29.40 -
   29.41 -	if (!xs_write(handles[handle], path, data, strlen(data), f))
   29.42 +	if (!xs_write(handles[handle], path, data, strlen(data)))
   29.43  		failed(handle);
   29.44  }
   29.45  
   29.46  static void do_noackwrite(unsigned int handle,
   29.47 -			  char *path, const char *flags, char *data)
   29.48 +			  char *path, char *data)
   29.49  {
   29.50  	struct xsd_sockmsg msg;
   29.51  
   29.52 -	/* Format: Flags (as string), path, data. */
   29.53 -	if (streq(flags, "none"))
   29.54 -		flags = XS_WRITE_NONE;
   29.55 -	else if (streq(flags, "create"))
   29.56 -		flags = XS_WRITE_CREATE;
   29.57 -	else if (streq(flags, "excl"))
   29.58 -		flags = XS_WRITE_CREATE_EXCL;
   29.59 -	else
   29.60 -		barf("noackwrite flags 'none', 'create' or 'excl' only");
   29.61 -
   29.62 -	msg.len = strlen(path) + 1 + strlen(flags) + 1 + strlen(data);
   29.63 +	msg.len = strlen(path) + 1 + strlen(data);
   29.64  	msg.type = XS_WRITE;
   29.65  	if (!write_all_choice(handles[handle]->fd, &msg, sizeof(msg)))
   29.66  		failed(handle);
   29.67  	if (!write_all_choice(handles[handle]->fd, path, strlen(path) + 1))
   29.68  		failed(handle);
   29.69 -	if (!write_all_choice(handles[handle]->fd, flags, strlen(flags) + 1))
   29.70 -		failed(handle);
   29.71  	if (!write_all_choice(handles[handle]->fd, data, strlen(data)))
   29.72  		failed(handle);
   29.73  	/* Do not wait for ack. */
   29.74 @@ -778,8 +753,7 @@ static void do_command(unsigned int defa
   29.75  	else if (streq(command, "read"))
   29.76  		do_read(handle, arg(line, 1));
   29.77  	else if (streq(command, "write"))
   29.78 -		do_write(handle,
   29.79 -			 arg(line, 1), arg(line, 2), arg(line, 3));
   29.80 +		do_write(handle, arg(line, 1), arg(line, 2));
   29.81  	else if (streq(command, "setid"))
   29.82  		do_setid(handle, arg(line, 1));
   29.83  	else if (streq(command, "mkdir"))
   29.84 @@ -832,7 +806,7 @@ static void do_command(unsigned int defa
   29.85  		xs_daemon_close(handles[handle]);
   29.86  		handles[handle] = NULL;
   29.87  	} else if (streq(command, "noackwrite"))
   29.88 -		do_noackwrite(handle, arg(line,1), arg(line,2), arg(line,3));
   29.89 +		do_noackwrite(handle, arg(line,1), arg(line,2));
   29.90  	else if (streq(command, "readack"))
   29.91  		do_readack(handle);
   29.92  	else