[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-tools] Re: [PATCH] Remove xs_write flags



Thanks!

On Sat, Sep 17, 2005 at 10:15:51AM +1000, Rusty Russell wrote:
> # HG changeset patch
> # User Rusty Russell <rusty@xxxxxxxxxxxxxxx>
> # Node ID a678d0c04c92a555cc8e592a51ed294e5cc9c021
> # Parent  90b4e122d3407c7d0e28e6391ca89d46d5a81e52
> 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".
> 
> diff -r 90b4e122d340 -r a678d0c04c92 tools/blktap/xenbus.c
> --- a/tools/blktap/xenbus.c   Fri Sep 16 05:01:11 2005
> +++ b/tools/blktap/xenbus.c   Fri Sep 16 06:46:15 2005
> @@ -92,7 +92,7 @@
>          if ((path == NULL) || (buf == NULL))
>              return 0;
>  
> -        ret = xs_write(h, path, buf, strlen(buf)+1, O_CREAT);
> +        ret = xs_write(h, path, buf, strlen(buf)+1);
>  
>          free(buf);
>          free(path);
> diff -r 90b4e122d340 -r a678d0c04c92 tools/console/daemon/io.c
> --- a/tools/console/daemon/io.c       Fri Sep 16 05:01:11 2005
> +++ b/tools/console/daemon/io.c       Fri Sep 16 06:46:15 2005
> @@ -165,7 +165,7 @@
>               success = asprintf(&path, "%s/tty", dom->conspath) != -1;
>               if (!success)
>                       goto out;
> -             success = xs_write(xs, path, slave, strlen(slave), O_CREAT);
> +             success = xs_write(xs, path, slave, strlen(slave));
>               free(path);
>               if (!success)
>                       goto out;
> diff -r 90b4e122d340 -r a678d0c04c92 tools/python/xen/lowlevel/xs/xs.c
> --- a/tools/python/xen/lowlevel/xs/xs.c       Fri Sep 16 05:01:11 2005
> +++ b/tools/python/xen/lowlevel/xs/xs.c       Fri Sep 16 06:46:15 2005
> @@ -116,8 +116,6 @@
>       "Write data to a path.\n"                               \
>       " path   [string] : xenstore path to write to\n."       \
>       " data   [string] : data to write.\n"                   \
> -     " create [int]    : create flag, default 0.\n"          \
> -     " excl   [int]    : exclusive flag, default 0.\n"       \
>       "\n"                                                    \
>       "Returns None on success.\n"                            \
>       "Raises RuntimeError on error.\n"                       \
> @@ -125,30 +123,23 @@
>  
>  static PyObject *xspy_write(PyObject *self, PyObject *args, PyObject *kwds)
>  {
> -    static char *kwd_spec[] = { "path", "data", "create", "excl", NULL };
> -    static char *arg_spec = "ss#|ii";
> +    static char *kwd_spec[] = { "path", "data", NULL };
> +    static char *arg_spec = "ss#";
>      char *path = NULL;
>      char *data = NULL;
>      int data_n = 0;
> -    int create = 0;
> -    int excl = 0;
> -
> -    struct xs_handle *xh = xshandle(self);
> -    PyObject *val = NULL;
> -    int flags = 0;
> +
> +    struct xs_handle *xh = xshandle(self);
> +    PyObject *val = NULL;
>      int xsval = 0;
>  
>      if (!xh)
>          goto exit;
>      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
> -                                     &path, &data, &data_n, &create, &excl))
> -        goto exit;
> -    if (create)
> -        flags |= O_CREAT;
> -    if (excl)
> -        flags |= O_EXCL;
> -    Py_BEGIN_ALLOW_THREADS
> -    xsval = xs_write(xh, path, data, data_n, flags);
> +                                     &path, &data, &data_n))
> +        goto exit;
> +    Py_BEGIN_ALLOW_THREADS
> +    xsval = xs_write(xh, path, data, data_n);
>      Py_END_ALLOW_THREADS
>      if (!xsval) {
>          PyErr_SetFromErrno(PyExc_RuntimeError);
> diff -r 90b4e122d340 -r a678d0c04c92 tools/python/xen/xend/xenstore/xsnode.py
> --- a/tools/python/xen/xend/xenstore/xsnode.py        Fri Sep 16 05:01:11 2005
> +++ b/tools/python/xen/xend/xenstore/xsnode.py        Fri Sep 16 06:46:15 2005
> @@ -255,7 +255,7 @@
>              if x == "": continue
>              p = os.path.join(p, x)
>              if not self.exists(p):
> -                self.getxs().write(p, "", create=True)
> +                self.getxs().write(p, "")
>  
>      def read(self, path):
>          try:
> @@ -266,13 +266,12 @@
>              else:
>                  raise
>  
> -    def create(self, path, excl=False):
> -        self.write(path, "", create=True, excl=excl)
> -
> -    def write(self, path, data, create=True, excl=False):
> -        self.mkdirs(path)
> -        try:
> -            self.getxs().write(path, data, create=create, excl=excl)
> +    def create(self, path):
> +        self.write(path, "")
> +
> +    def write(self, path, data):
> +        try:
> +            self.getxs().write(path, data)
>          except Exception, ex:
>              raise
>  
> diff -r 90b4e122d340 -r a678d0c04c92 
> tools/python/xen/xend/xenstore/xstransact.py
> --- a/tools/python/xen/xend/xenstore/xstransact.py    Fri Sep 16 05:01:11 2005
> +++ b/tools/python/xen/xend/xenstore/xstransact.py    Fri Sep 16 06:46:15 2005
> @@ -53,13 +53,11 @@
>              ret.append(self._read(key))
>          return ret
>  
> -    def _write(self, key, data, create=True, excl=False):
> -        path = "%s/%s" % (self.path, key)
> -        xshandle().write(path, data, create=create, excl=excl)
> +    def _write(self, key, data):
> +        path = "%s/%s" % (self.path, key)
> +        xshandle().write(path, data)
>  
>      def write(self, *args, **opts):
> -        create = opts.get('create') or True
> -        excl = opts.get('excl') or False
>          if len(args) == 0:
>              raise TypeError
>          if isinstance(args[0], dict):
> @@ -67,15 +65,15 @@
>                  if not isinstance(d, dict):
>                      raise TypeError
>                  for key in d.keys():
> -                    self._write(key, d[key], create, excl)
> +                    self._write(key, d[key])
>          elif isinstance(args[0], list):
>              for l in args:
>                  if not len(l) == 2:
>                      raise TypeError
> -                self._write(l[0], l[1], create, excl)
> +                self._write(l[0], l[1])
>          elif len(args) % 2 == 0:
>              for i in range(len(args) / 2):
> -                self._write(args[i * 2], args[i * 2 + 1], create, excl)
> +                self._write(args[i * 2], args[i * 2 + 1])
>          else:
>              raise TypeError
>  
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/testsuite/01simple.test
> --- a/tools/xenstore/testsuite/01simple.test  Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/01simple.test  Fri Sep 16 06:46:15 2005
> @@ -1,4 +1,4 @@
>  # Create an entry, read it.
> -write /test create contents
> +write /test contents
>  expect contents
>  read /test
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/testsuite/02directory.test
> --- a/tools/xenstore/testsuite/02directory.test       Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/02directory.test       Fri Sep 16 06:46:15 2005
> @@ -3,7 +3,7 @@
>  dir /
>  
>  # Create a file.
> -write /test create contents
> +write /test contents
>  
>  # Directory shows it.
>  expect test
> @@ -21,7 +21,7 @@
>  dir /dir
>  
>  # Create a file, check it exists.
> -write /dir/test2 create contents2
> +write /dir/test2 contents2
>  expect test2
>  dir /dir
>  expect contents2
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/testsuite/03write.test
> --- a/tools/xenstore/testsuite/03write.test   Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/03write.test   Fri Sep 16 06:46:15 2005
> @@ -1,31 +1,20 @@
> -# Write without create fails.
> -expect write failed: No such file or directory
> -write /test none contents
> -
> -# Exclusive write succeeds
> -write /test excl contents
> +# Write succeeds
> +write /test contents
>  expect contents
>  read /test
>  
> -# Exclusive write fails to overwrite.
> -expect write failed: File exists
> -write /test excl contents
> -
> -# Non-exclusive overwrite succeeds.
> -write /test none contents2
> +# Overwrite succeeds.
> +write /test contents2
>  expect contents2
> -read /test
> -write /test create contents3
> -expect contents3
>  read /test
>  
>  # Write should implicitly create directories
> -write /dir/test create contents
> +write /dir/test contents
>  expect test
>  dir /dir
>  expect contents
>  read /dir/test
> -write /dir/1/2/3/4 excl contents4
> +write /dir/1/2/3/4 contents4
>  expect test
>  expect 1
>  dir /dir
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/testsuite/04rm.test
> --- a/tools/xenstore/testsuite/04rm.test      Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/04rm.test      Fri Sep 16 06:46:15 2005
> @@ -4,7 +4,7 @@
>  rm /dir/test
>  
>  # Create file and remove it
> -write /test excl contents
> +write /test contents
>  rm /test
>  
>  # Create directory and remove it.
> @@ -13,5 +13,5 @@
>  
>  # Create directory, create file, remove all.
>  mkdir /dir
> -write /dir/test excl contents
> +write /dir/test contents
>  rm /dir
> diff -r 90b4e122d340 -r a678d0c04c92 
> tools/xenstore/testsuite/05filepermissions.test
> --- a/tools/xenstore/testsuite/05filepermissions.test Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/05filepermissions.test Fri Sep 16 06:46:15 2005
> @@ -5,7 +5,7 @@
>  getperm /dir/test
>  
>  # Create file: inherits from root (0 READ)
> -write /test excl contents
> +write /test contents
>  expect 0 READ
>  getperm /test
>  setid 1
> @@ -14,7 +14,7 @@
>  expect contents
>  read /test
>  expect write failed: Permission denied
> -write /test none contents
> +write /test contents
>  
>  # Take away read access to file.
>  setid 0
> @@ -25,7 +25,7 @@
>  expect read failed: Permission denied
>  read /test
>  expect write failed: Permission denied
> -write /test none contents
> +write /test contents
>  
>  # Grant everyone write access to file.
>  setid 0
> @@ -35,7 +35,7 @@
>  getperm /test
>  expect read failed: Permission denied
>  read /test
> -write /test none contents2
> +write /test contents2
>  setid 0
>  expect contents2
>  read /test
> @@ -47,7 +47,7 @@
>  getperm /test
>  expect contents2
>  read /test
> -write /test none contents3
> +write /test contents3
>  expect contents3
>  read /test
>  
> @@ -59,7 +59,7 @@
>  getperm /test
>  expect contents3
>  read /test
> -write /test none contents4
> +write /test contents4
>  
>  # User 2 can do nothing.
>  setid 2
> @@ -70,7 +70,7 @@
>  expect read failed: Permission denied
>  read /test
>  expect write failed: Permission denied
> -write /test none contents4
> +write /test contents4
>  
>  # Tools can always access things.
>  setid 0
> @@ -78,4 +78,4 @@
>  getperm /test
>  expect contents4
>  read /test
> -write /test none contents5
> +write /test contents5
> diff -r 90b4e122d340 -r a678d0c04c92 
> tools/xenstore/testsuite/06dirpermissions.test
> --- a/tools/xenstore/testsuite/06dirpermissions.test  Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/06dirpermissions.test  Fri Sep 16 06:46:15 2005
> @@ -11,7 +11,7 @@
>  getperm /dir
>  dir /dir
>  expect write failed: Permission denied
> -write /dir/test create contents2
> +write /dir/test contents2
>  
>  # Remove everyone's read access to directoy.
>  setid 0
> @@ -22,7 +22,7 @@
>  expect read failed: Permission denied
>  read /dir/test create contents2
>  expect write failed: Permission denied
> -write /dir/test create contents2
> +write /dir/test contents2
>  
>  # Grant everyone write access to directory.
>  setid 0
> @@ -32,7 +32,7 @@
>  getperm /dir
>  expect dir failed: Permission denied
>  dir /dir
> -write /dir/test create contents
> +write /dir/test contents
>  setid 0
>  expect 1 WRITE
>  getperm /dir/test
> @@ -47,7 +47,7 @@
>  getperm /dir
>  expect test
>  dir /dir
> -write /dir/test2 create contents
> +write /dir/test2 contents
>  expect contents
>  read /dir/test2
>  setperm /dir/test2 1 NONE
> @@ -60,7 +60,7 @@
>  expect test
>  expect test2
>  dir /dir
> -write /dir/test3 create contents
> +write /dir/test3 contents
>  
>  # User 2 can do nothing.  Can't even tell if file exists.
>  setid 2
> @@ -79,17 +79,9 @@
>  expect read failed: Permission denied
>  read /dir/test4
>  expect write failed: Permission denied
> -write /dir/test none contents
> +write /dir/test contents
>  expect write failed: Permission denied
> -write /dir/test create contents
> -expect write failed: Permission denied
> -write /dir/test excl contents
> -expect write failed: Permission denied
> -write /dir/test4 none contents
> -expect write failed: Permission denied
> -write /dir/test4 create contents
> -expect write failed: Permission denied
> -write /dir/test4 excl contents
> +write /dir/test4 contents
>  
>  # Tools can always access things.
>  setid 0
> @@ -99,13 +91,13 @@
>  expect test2
>  expect test3
>  dir /dir
> -write /dir/test4 create contents
> +write /dir/test4 contents
>  
>  # Inherited by child.
>  mkdir /dir/subdir
>  expect 1 NONE
>  getperm /dir/subdir
> -write /dir/subfile excl contents
> +write /dir/subfile contents
>  expect 1 NONE
>  getperm /dir/subfile
>  
> @@ -114,12 +106,12 @@
>  expect 2 READ/WRITE
>  getperm /dir/subdir
>  setid 3
> -write /dir/subdir/subfile excl contents
> +write /dir/subdir/subfile contents
>  expect 3 READ/WRITE
>  getperm /dir/subdir/subfile
>  
>  # Inheritence works through multiple directories, too.
> -write /dir/subdir/1/2/3/4 excl contents
> +write /dir/subdir/1/2/3/4 contents
>  expect 3 READ/WRITE
>  getperm /dir/subdir/1/2/3/4
>  mkdir /dir/subdir/a/b/c/d
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/testsuite/07watch.test
> --- a/tools/xenstore/testsuite/07watch.test   Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/07watch.test   Fri Sep 16 06:46:15 2005
> @@ -1,8 +1,8 @@
>  # Watch something, write to it, check watch has fired.
> -write /test create contents
> +write /test contents
>  
>  1 watch /test token
> -2 write /test create contents2
> +2 write /test contents2
>  expect 1:/test:token
>  1 waitwatch
>  1 ackwatch token
> @@ -44,7 +44,7 @@
>  
>  # ignore watches while doing commands, should work.
>  watch /dir token
> -1 write /dir/test create contents
> +1 write /dir/test contents
>  expect contents
>  read /dir/test
>  expect /dir/test:token
> @@ -56,7 +56,7 @@
>  1 watch /dir token1
>  3 watch /dir token3
>  2 watch /dir token2
> -write /dir/test create contents
> +write /dir/test contents
>  expect 3:/dir/test:token3
>  3 waitwatch
>  3 ackwatch token3
> @@ -73,7 +73,7 @@
>  # If one dies (without acking), the other should still get ack.
>  1 watch /dir token1
>  2 watch /dir token2
> -write /dir/test create contents
> +write /dir/test contents
>  expect 2:/dir/test:token2
>  2 waitwatch
>  2 close
> @@ -85,7 +85,7 @@
>  # If one dies (without reading at all), the other should still get ack.
>  1 watch /dir token1
>  2 watch /dir token2
> -write /dir/test create contents
> +write /dir/test contents
>  2 close
>  expect 1:/dir/test:token1
>  1 waitwatch
> @@ -97,7 +97,7 @@
>  1 watch /dir token1
>  1 unwatch /dir token1
>  1 watch /dir token2
> -2 write /dir/test2 create contents
> +2 write /dir/test2 contents
>  expect 1:/dir/test2:token2
>  1 waitwatch
>  1 unwatch /dir token2
> @@ -107,7 +107,7 @@
>  # unwatch while watch pending.  Other watcher still gets the event.
>  1 watch /dir token1
>  2 watch /dir token2
> -write /dir/test create contents
> +write /dir/test contents
>  2 unwatch /dir token2
>  expect 1:/dir/test:token1
>  1 waitwatch
> @@ -117,17 +117,17 @@
>  
>  # unwatch while watch pending.  Should clear this so we get next event.
>  1 watch /dir token1
> -write /dir/test create contents
> +write /dir/test contents
>  1 unwatch /dir token1
>  1 watch /dir/test token2
> -write /dir/test none contents2
> +write /dir/test contents2
>  expect 1:/dir/test:token2
>  1 waitwatch
>  1 ackwatch token2
>  
>  # check we only get notified once.
>  1 watch /test token
> -2 write /test create contents2
> +2 write /test contents2
>  expect 1:/test:token
>  1 waitwatch
>  1 ackwatch token
> @@ -137,9 +137,9 @@
>  
>  # watches are queued in order.
>  1 watch / token
> -2 write /test1 create contents
> -2 write /test2 create contents
> -2 write /test3 create contents
> +2 write /test1 contents
> +2 write /test2 contents
> +2 write /test3 contents
>  expect 1:/test1:token
>  1 waitwatch
>  1 ackwatch token
> @@ -153,8 +153,8 @@
>  
>  # Creation of subpaths should be covered correctly.
>  1 watch / token
> -2 write /test/subnode create contents2
> -2 write /test/subnode/subnode create contents2
> +2 write /test/subnode contents2
> +2 write /test/subnode/subnode contents2
>  expect 1:/test/subnode:token
>  1 waitwatch
>  1 ackwatch token
> @@ -167,7 +167,7 @@
>  
>  # Watch event must have happened before we registered interest.
>  1 watch / token
> -2 write /test/subnode create contents2
> +2 write /test/subnode contents2
>  1 watch / token2 0
>  expect 1:/test/subnode:token
>  1 waitwatch
> @@ -185,7 +185,7 @@
>  
>  # Watch should not double-send after we ack, even if we did something in 
> between.
>  1 watch /test2 token
> -2 write /test2/foo create contents2
> +2 write /test2/foo contents2
>  expect 1:/test2/foo:token
>  1 waitwatch
>  expect 1:contents2
> diff -r 90b4e122d340 -r a678d0c04c92 
> tools/xenstore/testsuite/08transaction.slowtest
> --- a/tools/xenstore/testsuite/08transaction.slowtest Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/08transaction.slowtest Fri Sep 16 06:46:15 2005
> @@ -1,7 +1,7 @@
>  # Test transaction timeouts.  Take a second each.
>  
>  mkdir /test
> -write /test/entry1 create contents
> +write /test/entry1 contents
>  
>  # Transactions can take as long as the want...
>  start /test
> diff -r 90b4e122d340 -r a678d0c04c92 
> tools/xenstore/testsuite/08transaction.test
> --- a/tools/xenstore/testsuite/08transaction.test     Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/08transaction.test     Fri Sep 16 06:46:15 2005
> @@ -4,7 +4,7 @@
>  
>  # Simple transaction: create a file inside transaction.
>  1 start /test
> -1 write /test/entry1 create contents
> +1 write /test/entry1 contents
>  2 dir /test
>  expect 1:entry1
>  1 dir /test
> @@ -16,14 +16,14 @@
>  
>  # Create a file and abort transaction.
>  1 start /test
> -1 write /test/entry1 create contents
> +1 write /test/entry1 contents
>  2 dir /test
>  expect 1:entry1
>  1 dir /test
>  1 abort
>  2 dir /test
>  
> -write /test/entry1 create contents
> +write /test/entry1 contents
>  # Delete in transaction, commit
>  1 start /test
>  1 rm /test/entry1
> @@ -34,7 +34,7 @@
>  2 dir /test
>  
>  # Delete in transaction, abort.
> -write /test/entry1 create contents
> +write /test/entry1 contents
>  1 start /test
>  1 rm /test/entry1
>  expect 2:entry1
> @@ -84,8 +84,8 @@
>  # Multiple events from single transaction don't trigger assert
>  1 watch /test token
>  2 start /test
> -2 write /test/1 create contents
> -2 write /test/2 create contents
> +2 write /test/1 contents
> +2 write /test/2 contents
>  2 commit
>  expect 1:/test/1:token
>  1 waitwatch
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/testsuite/09domain.test
> --- a/tools/xenstore/testsuite/09domain.test  Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/09domain.test  Fri Sep 16 06:46:15 2005
> @@ -3,7 +3,7 @@
>  # Create a domain, write an entry.
>  expect handle is 1
>  introduce 1 100 7 /my/home
> -1 write /entry1 create contents
> +1 write /entry1 contents
>  expect entry1
>  expect tool
>  dir /
> diff -r 90b4e122d340 -r a678d0c04c92 
> tools/xenstore/testsuite/10domain-homedir.test
> --- a/tools/xenstore/testsuite/10domain-homedir.test  Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/10domain-homedir.test  Fri Sep 16 06:46:15 2005
> @@ -4,7 +4,7 @@
>  mkdir /home
>  expect handle is 1
>  introduce 1 100 7 /home
> -1 write entry1 create contents
> +1 write entry1 contents
>  expect contents
>  read /home/entry1
>  expect entry1
> @@ -13,7 +13,7 @@
>  # Place a watch using a relative path: expect relative answer.
>  1 mkdir foo
>  1 watch foo token
> -write /home/foo/bar create contents
> +write /home/foo/bar contents
>  expect 1:foo/bar:token
>  1 waitwatch
>  1 ackwatch token
> diff -r 90b4e122d340 -r a678d0c04c92 
> tools/xenstore/testsuite/11domain-watch.test
> --- a/tools/xenstore/testsuite/11domain-watch.test    Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/11domain-watch.test    Fri Sep 16 06:46:15 2005
> @@ -1,13 +1,13 @@
>  # Test watching from a domain.
>  
>  # Watch something, write to it, check watch has fired.
> -write /test create contents
> +write /test contents
>  mkdir /dir
>  
>  expect handle is 1
>  introduce 1 100 7 /my/home
>  1 watch /test token
> -write /test create contents2
> +write /test contents2
>  expect 1:/test:token
>  1 waitwatch
>  1 ackwatch token
> @@ -19,10 +19,10 @@
>  expect handle is 1
>  introduce 1 100 7 /my/home
>  1 watch /dir token
> -write /dir/test create contents
> -1 write /dir/test2 create contents2
> -1 write /dir/test3 create contents3
> -1 write /dir/test4 create contents4
> +write /dir/test contents
> +1 write /dir/test2 contents2
> +1 write /dir/test3 contents3
> +1 write /dir/test4 contents4
>  expect 1:/dir/test:token
>  1 waitwatch
>  1 ackwatch token
> @@ -35,7 +35,7 @@
>  1 watch /dir token1
>  1 unwatch /dir token1
>  1 watch /dir token2
> -write /dir/test2 create contents
> +write /dir/test2 contents
>  expect 1:/dir/test2:token2
>  1 waitwatch
>  1 unwatch /dir token2
> @@ -46,7 +46,7 @@
>  expect handle is 1
>  introduce 1 100 7 /my/home
>  1 watch /dir token1
> -write /dir/test2 create contents
> +write /dir/test2 contents
>  1 unwatch /dir token1
>  release 1
>  1 close
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/testsuite/12readonly.test
> --- a/tools/xenstore/testsuite/12readonly.test        Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/12readonly.test        Fri Sep 16 06:46:15 2005
> @@ -1,6 +1,6 @@
>  # Test that read only connection can't alter store.
>  
> -write /test create contents
> +write /test contents
>  
>  readonly
>  expect test
> @@ -20,9 +20,9 @@
>  
>  # These don't work
>  expect write failed: Read-only file system
> -write /test2 create contents
> +write /test2 contents
>  expect write failed: Read-only file system
> -write /test create contents
> +write /test contents
>  expect setperm failed: Read-only file system
>  setperm /test 100 NONE
>  expect setperm failed: Read-only file system
> @@ -35,7 +35,7 @@
>  # Check that watches work like normal.
>  watch / token
>  1 readwrite
> -1 write /test create contents
> +1 write /test contents
>  expect /test:token
>  waitwatch
>  ackwatch token
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/testsuite/13watch-ack.test
> --- a/tools/xenstore/testsuite/13watch-ack.test       Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/13watch-ack.test       Fri Sep 16 06:46:15 2005
> @@ -13,10 +13,10 @@
>  1 watch /test/1 token1
>  1 watch /test/2 token2
>  1 watch /test/3 token3
> -2 write /test/2 create contents2
> +2 write /test/2 contents2
>  expect 1:/test/2:token2
>  1 waitwatch
> -3 write /test/1 create contents1
> -4 write /test/3 create contents3
> +3 write /test/1 contents1
> +4 write /test/3 contents3
>  1 ackwatch token2
>  1 close
> diff -r 90b4e122d340 -r a678d0c04c92 
> tools/xenstore/testsuite/14complexperms.test
> --- a/tools/xenstore/testsuite/14complexperms.test    Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/14complexperms.test    Fri Sep 16 06:46:15 2005
> @@ -12,13 +12,7 @@
>  expect *Permission denied
>  read /dir/file 
>  expect *Permission denied
> -write /dir/file none value 
> -expect *Permission denied
> -write /dir/file create value 
> -expect *Permission denied
> -write /dir/file excl value 
> -expect write failed: Invalid argument
> -write /dir/file crap value 
> +write /dir/file value 
>  expect *Permission denied
>  mkdir /dir/file 
>  expect *Permission denied
> @@ -30,7 +24,7 @@
>  expect *Permission denied
>  setperm /dir/file 0 NONE 
>  watch /dir/file token 
> -1 write /dir/file create contents
> +1 write /dir/file contents
>  1 rm /dir/file
>  expect waitwatch failed: Connection timed out
>  waitwatch
> @@ -50,7 +44,7 @@
>  
>  # Now it exists
>  setid 0
> -write /dir/file create contents
> +write /dir/file contents
>  
>  setid 1
>  expect *Permission denied
> @@ -58,13 +52,7 @@
>  expect *Permission denied
>  read /dir/file 
>  expect *Permission denied
> -write /dir/file none value 
> -expect *Permission denied
> -write /dir/file create value 
> -expect *Permission denied
> -write /dir/file excl value 
> -expect write failed: Invalid argument
> -write /dir/file crap value 
> +write /dir/file value 
>  expect *Permission denied
>  mkdir /dir/file 
>  expect *Permission denied
> @@ -76,7 +64,7 @@
>  expect *Permission denied
>  setperm /dir/file 0 NONE 
>  watch /dir/file token 
> -1 write /dir/file create contents
> +1 write /dir/file contents
>  1 rm /dir/file
>  expect waitwatch failed: Connection timed out
>  waitwatch
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/testsuite/15nowait.test
> --- a/tools/xenstore/testsuite/15nowait.test  Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/testsuite/15nowait.test  Fri Sep 16 06:46:15 2005
> @@ -1,10 +1,10 @@
>  # If we don't wait for an ack, we can crash daemon as it never expects to be
>  # sending out two replies on top of each other.
> -noackwrite /1 create 1
> -noackwrite /2 create 2
> -noackwrite /3 create 3
> -noackwrite /4 create 4
> -noackwrite /5 create 5
> +noackwrite /1 1
> +noackwrite /2 2
> +noackwrite /3 3
> +noackwrite /4 4
> +noackwrite /5 5
>  readack
>  readack
>  readack
> @@ -13,11 +13,11 @@
>  
>  expect handle is 1
>  introduce 1 100 7 /my/home
> -1 noackwrite /1 create 1
> -1 noackwrite /2 create 2
> -1 noackwrite /3 create 3
> -1 noackwrite /4 create 4
> -1 noackwrite /5 create 5
> +1 noackwrite /1 1
> +1 noackwrite /2 2
> +1 noackwrite /3 3
> +1 noackwrite /4 4
> +1 noackwrite /5 5
>  1 readack
>  1 readack
>  1 readack
> diff -r 90b4e122d340 -r a678d0c04c92 
> tools/xenstore/testsuite/16block-watch-crash.test
> --- a/tools/xenstore/testsuite/16block-watch-crash.test       Fri Sep 16 
> 05:01:11 2005
> +++ b/tools/xenstore/testsuite/16block-watch-crash.test       Fri Sep 16 
> 06:46:15 2005
> @@ -4,8 +4,8 @@
>  watch /test token
>  1 start /test
>  # This will block on above
> -noackwrite /test/entry create contents
> -1 write /test/entry2 create contents
> +noackwrite /test/entry contents
> +1 write /test/entry2 contents
>  1 commit
>  readack
>  expect /test/entry2:token
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/xenstored_core.c
> --- a/tools/xenstore/xenstored_core.c Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/xenstored_core.c Fri Sep 16 06:46:15 2005
> @@ -968,14 +968,12 @@
>       return lstat(node_dir(conn->transaction, node), &st) == 0;
>  }
>  
> -/* path, flags, data... */
> +/* path, data... */
>  static void do_write(struct connection *conn, struct buffered_data *in)
>  {
>       unsigned int offset, datalen;
> -     char *vec[2];
> +     char *vec[1] = { NULL }; /* gcc4 + -W + -Werror fucks code. */
>       char *node, *tmppath;
> -     enum xs_perm_type mode;
> -     struct stat st;
>  
>       /* Extra "strings" can be created by binary data. */
>       if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) {
> @@ -992,37 +990,20 @@
>       if (transaction_block(conn, node))
>               return;
>  
> -     offset = strlen(vec[0]) + strlen(vec[1]) + 2;
> +     offset = strlen(vec[0]) + 1;
>       datalen = in->used - offset;
>  
> -     if (streq(vec[1], XS_WRITE_NONE))
> -             mode = XS_PERM_WRITE;
> -     else if (streq(vec[1], XS_WRITE_CREATE))
> -             mode = XS_PERM_WRITE|XS_PERM_ENOENT_OK;
> -     else if (streq(vec[1], XS_WRITE_CREATE_EXCL))
> -             mode = XS_PERM_WRITE|XS_PERM_ENOENT_OK;
> -     else {
> -             send_error(conn, EINVAL);
> -             return;
> -     }
> -
> -     if (!check_node_perms(conn, node, mode)) {
> +     if (!check_node_perms(conn, node, XS_PERM_WRITE|XS_PERM_ENOENT_OK)) {
>               send_error(conn, errno);
>               return;
>       }
>  
> -     if (lstat(node_dir(conn->transaction, node), &st) != 0) {
> +     if (!node_exists(conn, node)) {
>               char *dir;
>  
>               /* Does not exist... */
>               if (errno != ENOENT) {
>                       send_error(conn, errno);
> -                     return;
> -             }
> -
> -             /* Not going to create it? */
> -             if (streq(vec[1], XS_WRITE_NONE)) {
> -                     send_error(conn, ENOENT);
>                       return;
>               }
>  
> @@ -1034,11 +1015,6 @@
>               
>       } else {
>               /* Exists... */
> -             if (streq(vec[1], XS_WRITE_CREATE_EXCL)) {
> -                     send_error(conn, EEXIST);
> -                     return;
> -             }
> -
>               tmppath = tempfile(node_datafile(conn->transaction, node),
>                                  in->buffer + offset, datalen);
>               if (!tmppath) {
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/xs.c
> --- a/tools/xenstore/xs.c     Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/xs.c     Fri Sep 16 06:46:15 2005
> @@ -326,32 +326,17 @@
>  }
>  
>  /* Write the value of a single file.
> - * Returns false on failure.  createflags can be 0, O_CREAT, or 
> O_CREAT|O_EXCL.
> + * Returns false on failure.
>   */
>  bool xs_write(struct xs_handle *h, const char *path,
> -           const void *data, unsigned int len, int createflags)
> -{
> -     const char *flags;
> -     struct iovec iovec[3];
> -
> -     /* Format: Flags (as string), path, data. */
> -     if (createflags == 0)
> -             flags = XS_WRITE_NONE;
> -     else if (createflags == O_CREAT)
> -             flags = XS_WRITE_CREATE;
> -     else if (createflags == (O_CREAT|O_EXCL))
> -             flags = XS_WRITE_CREATE_EXCL;
> -     else {
> -             errno = EINVAL;
> -             return false;
> -     }
> +           const void *data, unsigned int len)
> +{
> +     struct iovec iovec[2];
>  
>       iovec[0].iov_base = (void *)path;
>       iovec[0].iov_len = strlen(path) + 1;
> -     iovec[1].iov_base = (void *)flags;
> -     iovec[1].iov_len = strlen(flags) + 1;
> -     iovec[2].iov_base = (void *)data;
> -     iovec[2].iov_len = len;
> +     iovec[1].iov_base = (void *)data;
> +     iovec[1].iov_len = len;
>  
>       return xs_bool(xs_talkv(h, XS_WRITE, iovec, ARRAY_SIZE(iovec), NULL));
>  }
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/xs.h
> --- a/tools/xenstore/xs.h     Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/xs.h     Fri Sep 16 06:46:15 2005
> @@ -53,10 +53,10 @@
>  void *xs_read(struct xs_handle *h, const char *path, unsigned int *len);
>  
>  /* Write the value of a single file.
> - * Returns false on failure.  createflags can be 0, O_CREAT, or 
> O_CREAT|O_EXCL.
> + * Returns false on failure.
>   */
>  bool xs_write(struct xs_handle *h, const char *path, const void *data,
> -           unsigned int len, int createflags);
> +           unsigned int len);
>  
>  /* Create a new directory.
>   * Returns false on failure, or success if it already exists.
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/xs_crashme.c
> --- a/tools/xenstore/xs_crashme.c     Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/xs_crashme.c     Fri Sep 16 06:46:15 2005
> @@ -267,17 +267,12 @@
>               free(xs_read(h, name, &num));
>               break;
>       case 2: {
> -             int flags = random_flags(&state);
>               char *contents = talloc_asprintf(NULL, "%i",
>                                                get_randomness(&state));
>               unsigned int len = get_randomness(&state)%(strlen(contents)+1);
>               if (verbose)
> -                     printf("WRITE %s %s %.*s\n", name,
> -                            flags == O_CREAT ? "O_CREAT" 
> -                            : flags == (O_CREAT|O_EXCL) ? "O_CREAT|O_EXCL"
> -                            : flags == 0 ? "0" : "CRAPFLAGS",
> -                            len, contents);
> -             xs_write(h, name, contents, len, flags);
> +                     printf("WRITE %s %.*s\n", name, len, contents);
> +             xs_write(h, name, contents, len);
>               break;
>       }
>       case 3:
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/xs_random.c
> --- a/tools/xenstore/xs_random.c      Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/xs_random.c      Fri Sep 16 06:46:15 2005
> @@ -26,7 +26,7 @@
>       void *(*read)(void *h, const char *path, unsigned int *len);
>  
>       bool (*write)(void *h, const char *path, const void *data,
> -                   unsigned int len, int createflags);
> +                   unsigned int len);
>  
>       bool (*mkdir)(void *h, const char *path);
>  
> @@ -333,40 +333,18 @@
>  
>  static bool file_write(struct file_ops_info *info,
>                      const char *path, const void *data,
> -                    unsigned int len, int createflags)
> +                    unsigned int len)
>  {
>       char *filename = filename_to_data(path_to_name(info, path));
>       int fd;
>  
> -     /* Kernel isn't strict, but library is. */
> -     if (createflags & ~(O_CREAT|O_EXCL)) {
> -             errno = EINVAL;
> -             return false;
> -     }
> -
>       if (!write_ok(info, path))
>               return false;
>  
> -     /* We regard it as existing if dir exists. */
> -     if (strends(filename, ".DATA")) {
> -             if (!createflags)
> -                     createflags = O_CREAT;
> -             if (createflags & O_EXCL) {
> -                     errno = EEXIST;
> -                     return false;
> -             }
> -     }
> -
> -     if (createflags & O_CREAT)
> -             make_dirs(parent_filename(filename));
> -
> -     fd = open(filename, createflags|O_TRUNC|O_WRONLY, 0600);
> -     if (fd < 0) {
> -             /* FIXME: Another hack. */
> -             if (!(createflags & O_CREAT) && errno == EISDIR)
> -                     errno = EEXIST;
> +     make_dirs(parent_filename(filename));
> +     fd = open(filename, O_CREAT|O_TRUNC|O_WRONLY, 0600);
> +     if (fd < 0)
>               return false;
> -     }
>  
>       if (write(fd, data, len) != (int)len)
>               barf_perror("Bad write to %s", filename);
> @@ -846,20 +824,6 @@
>       return ret;
>  }
>  
> -static int random_flags(int *state)
> -{
> -     switch (get_randomness(state) % 4) {
> -     case 0:
> -             return 0;
> -     case 1:
> -             return O_CREAT;
> -     case 2:
> -             return O_CREAT|O_EXCL;
> -     default:
> -             return get_randomness(state);
> -     }
> -}
> -
>  /* Do the next operation, return the results. */
>  static char *do_next_op(struct ops *ops, void *h, int state, bool verbose)
>  {
> @@ -883,18 +847,12 @@
>               ret = linearize_read(ops->read(h, name, &num), &num);
>               break;
>       case 2: {
> -             int flags = random_flags(&state);
>               char *contents = talloc_asprintf(NULL, "%i",
>                                                get_randomness(&state));
>               unsigned int len = get_randomness(&state)%(strlen(contents)+1);
>               if (verbose)
> -                     printf("WRITE %s %s %.*s\n", name,
> -                            flags == O_CREAT ? "O_CREAT" 
> -                            : flags == (O_CREAT|O_EXCL) ? "O_CREAT|O_EXCL"
> -                            : flags == 0 ? "0" : "CRAPFLAGS",
> -                            len, contents);
> -             ret = bool_to_errstring(ops->write(h, name, contents, len,
> -                                                flags));
> +                     printf("WRITE %s %.*s\n", name, len, contents);
> +             ret = bool_to_errstring(ops->write(h, name, contents, len));
>               talloc_steal(ret, contents);
>               break;
>       }
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/xs_stress.c
> --- a/tools/xenstore/xs_stress.c      Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/xs_stress.c      Fri Sep 16 06:46:15 2005
> @@ -61,7 +61,7 @@
>                       barf_perror("%i: can't read %s iter %i",
>                                   childnum, file, i);
>               sprintf(tmp, "%i", atoi(contents) + 1);
> -             if (!xs_write(h, file, tmp, strlen(tmp)+1, 0))
> +             if (!xs_write(h, file, tmp, strlen(tmp)+1))
>                       barf_perror("%i: can't write %s iter %i",
>                                   childnum, file, i);
>  
> @@ -91,7 +91,7 @@
>  
>       if (togo == 0) {
>               sprintf(filename, "%s/count", base);
> -             if (!xs_write(h, filename, "0", 2, O_EXCL|O_CREAT))
> +             if (!xs_write(h, filename, "0", 1))
>                       barf_perror("Writing to %s", filename);
>               return;
>       }
> diff -r 90b4e122d340 -r a678d0c04c92 tools/xenstore/xs_test.c
> --- a/tools/xenstore/xs_test.c        Fri Sep 16 05:01:11 2005
> +++ b/tools/xenstore/xs_test.c        Fri Sep 16 06:46:15 2005
> @@ -192,7 +192,7 @@
>            "Reads commands from stdin, one per line:"
>            "  dir <path>\n"
>            "  read <path>\n"
> -          "  write <path> <flags> <value>...\n"
> +          "  write <path> <value>...\n"
>            "  setid <id>\n"
>            "  mkdir <path>\n"
>            "  rm <path>\n"
> @@ -213,7 +213,7 @@
>            "  notimeout\n"
>            "  readonly\n"
>            "  readwrite\n"
> -          "  noackwrite <path> <flags> <value>...\n"
> +          "  noackwrite <path> <value>...\n"
>            "  readack\n"
>            "  dump\n");
>  }
> @@ -348,47 +348,22 @@
>               output("%.*s\n", len, value);
>  }
>  
> -static void do_write(unsigned int handle, char *path, char *flags, char 
> *data)
> -{
> -     int f;
> -
> -     if (streq(flags, "none"))
> -             f = 0;
> -     else if (streq(flags, "create"))
> -             f = O_CREAT;
> -     else if (streq(flags, "excl"))
> -             f = O_CREAT | O_EXCL;
> -     else if (streq(flags, "crap"))
> -             f = 100;
> -     else
> -             barf("write flags 'none', 'create' or 'excl' only");
> -
> -     if (!xs_write(handles[handle], path, data, strlen(data), f))
> +static void do_write(unsigned int handle, char *path, char *data)
> +{
> +     if (!xs_write(handles[handle], path, data, strlen(data)))
>               failed(handle);
>  }
>  
>  static void do_noackwrite(unsigned int handle,
> -                       char *path, const char *flags, char *data)
> +                       char *path, char *data)
>  {
>       struct xsd_sockmsg msg;
>  
> -     /* Format: Flags (as string), path, data. */
> -     if (streq(flags, "none"))
> -             flags = XS_WRITE_NONE;
> -     else if (streq(flags, "create"))
> -             flags = XS_WRITE_CREATE;
> -     else if (streq(flags, "excl"))
> -             flags = XS_WRITE_CREATE_EXCL;
> -     else
> -             barf("noackwrite flags 'none', 'create' or 'excl' only");
> -
> -     msg.len = strlen(path) + 1 + strlen(flags) + 1 + strlen(data);
> +     msg.len = strlen(path) + 1 + strlen(data);
>       msg.type = XS_WRITE;
>       if (!write_all_choice(handles[handle]->fd, &msg, sizeof(msg)))
>               failed(handle);
>       if (!write_all_choice(handles[handle]->fd, path, strlen(path) + 1))
> -             failed(handle);
> -     if (!write_all_choice(handles[handle]->fd, flags, strlen(flags) + 1))
>               failed(handle);
>       if (!write_all_choice(handles[handle]->fd, data, strlen(data)))
>               failed(handle);
> @@ -778,8 +753,7 @@
>       else if (streq(command, "read"))
>               do_read(handle, arg(line, 1));
>       else if (streq(command, "write"))
> -             do_write(handle,
> -                      arg(line, 1), arg(line, 2), arg(line, 3));
> +             do_write(handle, arg(line, 1), arg(line, 2));
>       else if (streq(command, "setid"))
>               do_setid(handle, arg(line, 1));
>       else if (streq(command, "mkdir"))
> @@ -832,7 +806,7 @@
>               xs_daemon_close(handles[handle]);
>               handles[handle] = NULL;
>       } else if (streq(command, "noackwrite"))
> -             do_noackwrite(handle, arg(line,1), arg(line,2), arg(line,3));
> +             do_noackwrite(handle, arg(line,1), arg(line,2));
>       else if (streq(command, "readack"))
>               do_readack(handle);
>       else
> 
> -- 
> A bad analogy is like a leaky screwdriver -- Richard Braakman
> 
> 

_______________________________________________
Xen-tools mailing list
Xen-tools@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-tools


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.