From: Ian Campbell Subject: Re: [PATCH 07/19] libxl: provide libxl__xs_*_checked and libxl__xs_transaction_* Date: Wed, 13 Jun 2012 12:15:59 +0100 Message-ID: <1339586159.24104.193.camel@zakaz.uk.xensource.com> References: <1339176870-32652-1-git-send-email-ian.jackson@eu.citrix.com> <1339176870-32652-8-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1339176870-32652-8-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Fri, 2012-06-08 at 18:34 +0100, Ian Jackson wrote: > These useful utility functions make dealing with xenstore a little > less painful. > > Signed-off-by: Ian Jackson Acked-by: Ian Campbell (minor observation and a typo below) [...] > +/* On success, *result_out came from the gc. > + * On error, *result_out is undefined. > + * ENOENT counts as success but sets *result_out=0 > + */ > +int libxl__xs_read_checked(libxl__gc *gc, xs_transaction_t t, > + const char *path, const char **result_out); > + > +/* Does not include a trailing null. > + * May usefully be combined with GCSPRINTF if the format string > + * behaviour of libxl__xs_write is desirable. */ > +int libxl__xs_write_checked(libxl__gc *gc, xs_transaction_t t, > + const char *path, const char *string); I suppose in the future we might consider merging this with libxl__xs_write -- there's no reason not to always log a failed write, is there? > + > +/* ENOENT is not an error (even if the parent directories don't exist) */ > +int libxl__xs_rm_checked(libxl__gc *gc, xs_transaction_t t, const char *path); > + > +/* Transaction functions, best used together. > + * The caller should initialise *t to 0 (XBT_NULL) before calling start. > + * Each function leaves *t!=0 iff the transaction needs cleaning up. > + * > + * libxl__xs_transaction_commit returns: > + * <0 failure - a libxl error code > + * +1 commit conflict; transaction has been destroyed and caller > + * must go round again (call _start again and retry) > + * 0 commited successfully committed > + */ > +int libxl__xs_transaction_start(libxl__gc *gc, xs_transaction_t *t); > +int libxl__xs_transaction_commit(libxl__gc *gc, xs_transaction_t *t); > +void libxl__xs_transaction_abort(libxl__gc *gc, xs_transaction_t *t); > + > + > + Ian.