X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=ucw%2Ffb-atomic.c;h=cd0217468279090b61ea69a19f816715254eecd9;hb=984b27ee84b371d605c1402784039b3803a25983;hp=fca0dfb6582ed997653bed9703e9a47cae45be61;hpb=903e6530eaa344851bf0aa6a9f270c205aa97300;p=libucw.git diff --git a/ucw/fb-atomic.c b/ucw/fb-atomic.c index fca0dfb6..cd021746 100644 --- a/ucw/fb-atomic.c +++ b/ucw/fb-atomic.c @@ -7,11 +7,11 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/fastbuf.h" -#include "ucw/lfs.h" -#include "ucw/conf.h" -#include "ucw/trans.h" +#include +#include +#include +#include +#include #include #include @@ -34,6 +34,7 @@ static void CONSTRUCTOR fbatomic_init_config(void) #endif +#define FB_ATOMIC(f) ((struct fb_atomic *)(f)) #define TRACE(m...) do { if(trace) msg(L_DEBUG, "FB_ATOMIC: " m); } while(0) struct fb_atomic_file { @@ -54,9 +55,9 @@ fbatomic_internal_write(struct fastbuf *f) ASSERT(af->record_len < 0 || !(size % af->record_len)); int res = write(af->fd, f->buffer, size); if (res < 0) - bthrow(f, "fb.write", "Error writing %s: %m", f->name); + bthrow(f, "write", "Error writing %s: %m", f->name); if (res != size) - bthrow(f, "fb.write", "Unexpected partial write to %s: written only %d bytes of %d", f->name, res, size); + bthrow(f, "write", "Unexpected partial write to %s: written only %d bytes of %d", f->name, res, size); f->bptr = f->buffer; } } @@ -77,6 +78,7 @@ fbatomic_spout(struct fastbuf *f) f->buffer = xrealloc(f->buffer, size); f->bufend = f->buffer + size; f->bptr = f->buffer + written; + f->bstop = f->buffer; F->expected_max_bptr = f->bufend - F->slack_size; } else @@ -113,7 +115,7 @@ fbatomic_open(const char *name, struct fastbuf *master, uns bufsize, int record_ { int fd = ucw_open(name, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, 0666); if (fd < 0) - trans_throw("fb.open", NULL, "Cannot create %s: %m", name); + trans_throw("ucw.fb.open", NULL, "Cannot create %s: %m", name); af = xmalloc_zero(sizeof(*af) + strlen(name)); af->fd = fd; af->use_count = 1; @@ -133,7 +135,7 @@ fbatomic_open(const char *name, struct fastbuf *master, uns bufsize, int record_ f->name = af->name; f->spout = fbatomic_spout; f->close = fbatomic_close; - return fb_tie(f); + return f; } #ifdef TEST