|
From: | Daniel Lehne |
Subject: | [bug-inetutils] syslogd - clog.patch - port clog from bsd version to inetutils linux |
Date: | Wed, 30 Nov 2011 09:50:29 +0200 |
User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
Hello, i've tried to create a patch for the inetutils, which adds a circular log functionality of Jeff Wheelhouse (http://software.wwwi.com/syslogd/) to the inetutils/syslogd. The patch is ported form BSD version of Jeff Wheelhouse to the inetuitls-1.6 version. The patch reference to the root dirctory "inetutils-1.6" and is created in the following way: quilt new clog quilt add Makefile.am clog/clog.8 clog/clog.c clog/clog.h clog/Makefile.am syslogd/syslogd.c syslogd/Makefile.am syslogd/syslog.conf.5 quilt refresh The patch is not working because of the following reasons. The clog tool is not included in build and the reasons are unkown. Changes in inetutils-1.6/configure.ac are failed to achieve this. The syslogd couldn't build because of missing clog.h in inetutils/lib, assuming that clog.h automatically copied to inetutils-1.6/lib in install process of clog. The syslogd depends on clog. All try to compile for an arm with OSELAS.Toolchain-2011.03.0 toolchain using ptx2. Any suggests, what's my mistake? Thanks for support! Best regards Daniel Lehne The patch contains the following: Index: inetutils-1.6/Makefile.am =================================================================== --- inetutils-1.6.orig/Makefile.am 2011-11-30 10:48:56.689500265 +0200 +++ inetutils-1.6/Makefile.am 2011-11-30 10:49:18.769499826 +0200 @@ -23,7 +23,7 @@ EXTRA_DIST = README-alpha paths ChangeLog.0 SUBDIRS = lib headers libinetutils libtelnet \ - hostname inetd telnetd libls ftpd rshd rlogind uucpd rexecd syslogd \ + hostname inetd telnetd libls ftpd rshd rlogind uucpd rexecd clog syslogd \ tftpd talkd telnet ftp rsh rcp rlogin tftp logger gwhois talk \ libicmp ping doc ifconfig traceroute tests Index: inetutils-1.6/clog/Makefile.am =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ inetutils-1.6/clog/Makefile.am 2011-11-30 10:49:18.769499826 +0200 @@ -0,0 +1,31 @@ +# Copyright (C) 2008 Free Software Foundation, Inc. +# This file is part of GNU Inetutils. +# +# GNU Inetutils is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Inetutils is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Inetutils; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin Street, +# Fifth Floor, Boston, MA 02110-1301 USA. + +bin_PROGRAMS = @clog_BUILD@ + +EXTRA_PROGRAMS = clog + +clog_SOURCES = clog.c + +man_MANS = clog.8 + +INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/libinetutils + +LDADD = -L$(top_builddir)/lib -lgnu + +EXTRA_DIST = $(man_MANS) Index: inetutils-1.6/clog/clog.8 =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ inetutils-1.6/clog/clog.8 2011-11-30 10:49:18.769499826 +0200 @@ -0,0 +1,98 @@ +.\" Copyright (c) 2001 +.\" Jeffrey D. Wheelhouse. All rights reserved. +.\" +.\" This code was originally developed by Jeff Wheelhouse (address@hidden). +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY JEFF WHEELHOUSE ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +.\" NO EVENT SHALL JEFF WHEELHOUSE BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT +.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +.\" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $Id: clog.8,v 1.2 2001/10/02 04:41:21 jdw Exp $ +.\" +.Dd October 1, 2001 +.Dt CLOG 8 +.Os BSD 4 +.Sh NAME +.Nm clog +.Nd "display or initialize a circular system log" +.Sh SYNOPSIS +.Nm +.Op Fl f +.Op Fl i Fl s Ar size +.Ar logfile +.Sh DESCRIPTION +.Nm Clog +displays or initializes a circular log file. +.Pp +The options are as follows: +.Bl -tag -width indent +.It Fl f +Display the contents of the circular logfile +.Ar logfile , +then go into a loop waiting for +new material to arrive. This is essentially the same as using the +.Fl f +option of the +.Xr tail 1 +command on a standard syslog file. +.It Fl i +Initialize +.Ar logfile +rather than reading it. This option requires the +.Fl s +option. If +.Ar logfile +already exists, it will be truncated and recreated by this command. +.It Fl s +This option specifies the size in bytes of the circular logfile that should +be created. This option requires the +.Fl i +option. +.El +.Sh ABOUT CIRCULAR LOGFILES +The +.Nm +command supports circular logfiles for +.Xr syslogd 8 . +A circular logfile differs from a standard syslog file in that is has a fixed +size. It does not grow, and does not need to be rotated. When +.Xr syslogd 8 +reaches the end of a circular logfile, it simply begins again at the beginning, +overwriting the oldest data. The circular logfile also contains information +allowing +.Nm +to establish what parts of the file are valid, and in what order they should +be displayed. +.Pp +Circular logfiles are primarily useful for their ability to control the amount +of storage devoted to logfiles. This may be valuable when storage space is +at a premium or when the consequences of running out of storage space are +unacceptable. Circular logfiles can safely be used on a memory disk (see +.Xr md 4 ). +.Pp +Circular logfiles are also useful to catch messages that are generated rapidly +but soon lose relevance, such as messages logged at debug priority. + +.Sh SEE ALSO +.Xr syslogd 8 , +.Xr syslog.conf 5 +.Sh HISTORY +The +.Nm +command was written for FreeBSD 4.3 but is not yet part of a BSD distribution. Index: inetutils-1.6/clog/clog.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ inetutils-1.6/clog/clog.c 2011-11-30 10:49:18.769499826 +0200 @@ -0,0 +1,226 @@ +/*- + * Copyright (c) 2001 + * Jeff Wheelhouse (address@hidden) + * + * This code was originally developed by Jeff Wheelhouse (address@hidden). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistribution of source code must retail the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JEFF WHEELHOUSE ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL JEFF WHEELHOUSE BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id: clog.c,v 1.3 2001/10/02 18:51:26 jdw Exp $ + */ + + +#include <assert.h> +#include <errno.h> +#include <fcntl.h> +#include <poll.h> +#include <sched.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <stdint.h> + +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/uio.h> + + +#include "clog.h" + + +/* + * The BUFFER_SIZE value is just used to allocate a buffer full of NULLs + * so that a new logfile can be extended to its full size. + * + * Compiling with -pedantic complains when the buffer array is declared + * if I declare this as a const instead of a #define. + */ +#define BUFFER_SIZE 16384 + +void init_log __P((const char *lname, size_t size)); +void read_log __P((const char *lname, int optf)); +void usage __P((void)); + +const char *pname; + +int main(int argc, char **argv) { + int ch; + int init = 0; + int size = 0; + int optf = 0; + + pname = argv[0]; + + while ((ch = getopt(argc, argv, "fis:")) != -1) + switch(ch) { + case 'i': + init = 1; + break; + case 's': + size = atol(optarg); + if (size==0) usage(); + break; + case 'f': + optf = 1; + } + + if ((size>0)&&(init==0)) { + fprintf(stderr,"%s: WARNING: -s argument ignored without -i.\n",pname); + size = 0; + } + if (argv[optind]==NULL) { + fprintf(stderr,"%s: ERROR: log_file argument must be specified.\n",pname); + usage(); + } + if ((init==1)&&(size==0)) { + fprintf(stderr,"%s: ERROR: -i argument requires -s.\n",pname); + usage(); + } + if ((init==1)&&(optf==1)) { + fprintf(stderr,"%s: ERROR: flags -f and -i are incompatible.\n",pname); + usage(); + } + + if (init==1) init_log(argv[optind],size); + /* if (optf==1) follow_log(artv[optind]); */ + read_log(argv[optind],optf); + + return 0; +} + + +void usage() { + fprintf(stderr,"usage: %s [-i -s log_size] [ -f ] log_file\n",pname); + exit(1); +} + + +void read_log(const char *lname, int optf) { + int fd; + struct stat sb; + struct clog_footer *pcf; + char *pbuffer; + struct iovec iov[2]; + int iovcnt = 0; + uint32_t start = 0; + uint32_t next; + struct pollfd pfd; + + pfd.fd = -1; + + fd = open(lname,O_RDONLY); + if (fd==-1) { + fprintf(stderr,"%s: ERROR: could not open %s (%s)\n",pname,lname,strerror(errno)); + exit(11); + } + + if (fstat(fd,&sb)==-1) { + fprintf(stderr,"%s: ERROR: could not stat %s (%s)\n",pname,lname,strerror(errno)); + exit(13); + } + pbuffer = (char*)mmap(NULL,sb.st_size,PROT_READ,MAP_SHARED,fd,0); + if (pbuffer==NULL) { + fprintf(stderr,"%s: ERROR: could not mmap %s body (%s)\n",pname,lname,strerror(errno)); + exit(14); + } + pcf = (struct clog_footer*)(pbuffer + sb.st_size - sizeof(struct clog_footer)); + + if (pcf->cf_wrap==1) start = pcf->cf_next + 1; + while(1) { + while(pcf->cf_lock==1) sched_yield(); + next = pcf->cf_next; + iovcnt = 0; + if (start>next) { + iov[iovcnt].iov_base = pbuffer + start; + iov[iovcnt++].iov_len = pcf->cf_max - start; + start = 0; + } + iov[iovcnt].iov_base = pbuffer + start; + iov[iovcnt++].iov_len = next - start; + if (writev(1,iov,iovcnt)==-1) { + fprintf(stderr,"%s: ERROR: could not write output (%s)\n",pname,strerror(errno)); + exit(15); + } + start = next; + if (optf==0) break; + if (poll(&pfd,1,50)==-1) { + fprintf(stderr,"%s: ERROR: could not poll (%s)\n",pname,strerror(errno)); + exit(16); + } + } + + (void)munmap(pbuffer,sb.st_size); + (void)close(fd); + + exit(0); +} + + +void init_log(const char *lname, size_t size) { + int fd; + size_t fill = size; + char buffer[BUFFER_SIZE]; + struct clog_footer cf; + + memcpy(&cf.cf_magic,MAGIC_CONST,4); + cf.cf_max = size - sizeof(struct clog_footer); + + (void)memset(buffer,0,BUFFER_SIZE); + + fd = open(lname,O_RDWR|O_CREAT,0666); + if (fd==-1) { + fprintf(stderr,"%s: ERROR: could not open %s (%s)\n",pname,lname,strerror(errno)); + exit(2); + } + if (ftruncate(fd,(off_t)0)==-1) { + fprintf(stderr,"%s: ERROR: could not truncate %s (%s)\n",pname,lname,strerror(errno)); + exit(3); + } + + while(fill>BUFFER_SIZE) { + if (write(fd,buffer,BUFFER_SIZE)==-1){ + fprintf(stderr,"%s: ERROR: could not write %s (%s)\n",pname,lname,strerror(errno)); + exit(4); + } + fill -= BUFFER_SIZE; + } + assert(fill<=BUFFER_SIZE); + if (fill>0) { + if (write(fd,buffer,fill)==-1) { + fprintf(stderr,"%s: ERROR: could not write %s (%s)\n",pname,lname,strerror(errno)); + exit(5); + } + } + if (lseek(fd,-(off_t)(sizeof(struct clog_footer)),SEEK_END)==-1) { + fprintf(stderr,"%s: ERROR: could not seek in %s (%s)\n",pname,lname,strerror(errno)); + exit(6); + } + if (write(fd,&cf,sizeof(cf))==-1) { + fprintf(stderr,"%s: ERROR: could not write magic in %s (%s)\n",pname,lname,strerror(errno)); + exit(7); + } + (void)close(fd); + exit(0); +} + + Index: inetutils-1.6/clog/clog.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ inetutils-1.6/clog/clog.h 2011-11-30 10:49:18.769499826 +0200 @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2001 + * Jeff Wheelhouse (address@hidden) + * + * This code was originally developed by Jeff Wheelhouse (address@hidden). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistribution of source code must retail the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JEFF WHEELHOUSE ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL JEFF WHEELHOUSE BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id: clog.h,v 1.2 2001/10/02 04:43:52 jdw Exp $ + */ + + +#ifndef _CLOG_H_ +#define _CLOG_H_ + +/* + * This magic constant is used to identify a valid circular log file. + * syslogd will ignore any circular log file that doesn't have this constant. + */ + +const char MAGIC_CONST[5] = "CLOG"; + + +struct clog_footer { + uint32_t cf_magic; + uint32_t cf_wrap; + uint32_t cf_next; + uint32_t cf_max; + uint32_t cf_lock; +}; + + +#endif /* _CLOG_H_ */ + + Index: inetutils-1.6/syslogd/syslog.conf.5 =================================================================== --- inetutils-1.6.orig/syslogd/syslog.conf.5 2011-11-30 10:48:56.825498334 +0200 +++ inetutils-1.6/syslogd/syslog.conf.5 2011-11-30 10:49:18.769499826 +0200 @@ -197,6 +197,12 @@ Selected messages are written to those users if they are logged in. .It +A percent sign +.Pq Dq \&% , +followed by a pathname (beginning with a leading slash). Selected messages +are written to a circular log file. See clog(8) for a discussion of +circular log files. +.It An asterisk. Selected messages are written to all logged-in users. .El Index: inetutils-1.6/syslogd/syslogd.c =================================================================== --- inetutils-1.6.orig/syslogd/syslogd.c 2011-11-30 10:48:56.777498080 +0200 +++ inetutils-1.6/syslogd/syslogd.c 2011-11-30 10:49:18.773499498 +0200 @@ -137,6 +137,7 @@ #include <progname.h> #include <libinetutils.h> #include <readutmp.h> +#include <clog.h> /* A mask of all facilities mentioned explicitly in the configuration file * @@ -193,6 +194,11 @@ char *f_hname; struct sockaddr_in f_addr; } f_forw; /* Forwarding address. */ + struct { + char f_rname[MAXPATHLEN]; + struct clog_footer *f_footer; + size_t f_size; + } f_ring; /* circular file */ char *f_fname; /* Name use for Files|Pipes|TTYs. */ } f_un; char f_prevline[MAXSVLINE]; /* Last message logged. */ @@ -219,6 +225,7 @@ #define F_FORW_SUSP 7 /* Suspended host forwarding. */ #define F_FORW_UNKN 8 /* Unknown host forwarding. */ #define F_PIPE 9 /* Named pipe. */ +#define F_RING 10 /* ring buffer (circular log) */ const char *TypeNames[] = { "UNUSED", @@ -230,7 +237,8 @@ "WALL", "FORW(SUSPENDED)", "FORW(UNKNOWN)", - "PIPE" + "PIPE", + "CLOG" }; /* Flags in filed.f_flags. */ @@ -270,6 +278,8 @@ void printsys (const char *); char *ttymsg (struct iovec *, int, char *, int); void wallmsg (struct filed *, struct iovec *); +ssize_t rbwrite __P((struct filed *, char *, size_t)); +ssize_t rbwritev __P((struct filed *, struct iovec *, int)); char **crunch_list (char **oldlist, char *list); char *textpri (int pri); void dbg_toggle (int); @@ -279,6 +289,7 @@ static int create_unix_socket (const char *path); static int create_inet_socket (void); + char *LocalHostName; /* Our hostname. */ char *LocalDomain; /* Our local domain name. */ int finet = -1; /* Internet datagram socket fd. */ @@ -1277,6 +1288,21 @@ } break; + case F_RING: + dprintf(" %s\n", f->f_un.f_ring.f_rname); + v->iov_base = "\n"; + v->iov_len = 1; + if (rbwritev(f, iov, 7)==-1) { + int e = errno; + (void)munmap(f->f_un.f_ring.f_footer,sizeof(struct clog_footer)); + (void)close(f->f_file); + f->f_type = F_UNUSED; + errno = e; + logerror(f->f_un.f_fname); + } + + break; + case F_CONSOLE: f->f_time = now; if (flags & IGN_CONS) @@ -1595,6 +1621,10 @@ case F_PIPE: close (f->f_file); break; + case F_RING: + (void)munmap(f->f_un.f_ring.f_footer,sizeof(struct clog_footer)); + (void)close(f->f_file); + break; } next = f->f_next; free (f); @@ -1736,7 +1766,9 @@ case F_PIPE: dbg_printf ("%s", f->f_un.f_fname); break; - + case F_RING: + printf("%s", f->f_un.f_ring.f_rname); + break; case F_FORW: case F_FORW_SUSP: case F_FORW_UNKN: @@ -1772,6 +1804,7 @@ char *bp; const char *p, *q; char buf[MAXLINE], ebuf[200]; + struct stat sb; dbg_printf ("cfline(%s)\n", line); @@ -1953,6 +1986,39 @@ f->f_type = F_FILE; break; + /* circular log file */ + case '%': + if ((f->f_file = open(p+1, O_RDWR, 0 )) < 0) { + f->f_type = F_UNUSED; + logerror(p+1); + break; + } + if (fstat(f->f_file,&sb)<0) { + (void)close(f->f_file); + f->f_type = F_UNUSED; + logerror(p+1); + break; + } + f->f_un.f_ring.f_footer = mmap(NULL,sizeof(struct clog_footer),PROT_READ|PROT_WRITE,MAP_SHARED,f->f_file,sb.st_size-sizeof(struct clog_footer)); + if (f->f_un.f_ring.f_footer==NULL) { + (void)close(f->f_file); + f->f_type = F_UNUSED; + logerror(p+1); + break; + } + if (memcmp(&(f->f_un.f_ring.f_footer->cf_magic),MAGIC_CONST,4)!=0) { + (void)munmap(f->f_un.f_ring.f_footer,sizeof(struct clog_footer)); + (void)close(f->f_file); + f->f_type = F_UNUSED; + errno = ENODEV; + logerror(p+1); + break; + } + f->f_un.f_ring.f_size = sb.st_size; + (void)strcpy(f->f_un.f_ring.f_rname, p + 1); + f->f_type = F_RING; + break; + case '*': f->f_type = F_WALL; break; @@ -2042,3 +2108,48 @@ { restart = 1; } + +/* The following function handles the circular log file access */ +ssize_t rbwritev(struct filed *f, struct iovec *iov, int iovcnt) { + int i; + ssize_t out = 0; + ssize_t err; + + for(i=0;i<iovcnt;i++) { + err = rbwrite(f,iov[i].iov_base,iov[i].iov_len); + if (err==-1) return -1; + out += err; + } + return out; +} + + +ssize_t rbwrite(struct filed *f, char *buf, size_t nbytes) { + size_t maxwrite = f->f_un.f_ring.f_footer->cf_max - f->f_un.f_ring.f_footer->cf_next; + ssize_t err; + ssize_t out = 0; + + f->f_un.f_ring.f_footer->cf_lock = 1; + while (nbytes>0) { + maxwrite = f->f_un.f_ring.f_footer->cf_max - f->f_un.f_ring.f_footer->cf_next; + if (maxwrite>nbytes) maxwrite = nbytes; + err = pwrite(f->f_file,buf,maxwrite,f->f_un.f_ring.f_footer->cf_next); + if (err==-1) { + f->f_un.f_ring.f_footer->cf_lock = 0; + return -1; + } + nbytes -= err; + out += err; + buf += err; + f->f_un.f_ring.f_footer->cf_next += err; + if (f->f_un.f_ring.f_footer->cf_next==f->f_un.f_ring.f_footer->cf_max) { + f->f_un.f_ring.f_footer->cf_next = 0; + f->f_un.f_ring.f_footer->cf_wrap = 1; + } + + } + + f->f_un.f_ring.f_footer->cf_lock = 0; + return out; +} + |
[Prev in Thread] | Current Thread | [Next in Thread] |