fifolog_int.c (185790) | fifolog_int.c (219027) |
---|---|
1/*- 2 * Copyright (c) 2005-2008 Poul-Henning Kamp 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2005-2008 Poul-Henning Kamp 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/fifolog/lib/fifolog_int.c 185790 2008-12-09 09:25:03Z phk $ | 26 * $FreeBSD: head/usr.sbin/fifolog/lib/fifolog_int.c 219027 2011-02-25 09:40:17Z phk $ |
27 */ 28 29#include <assert.h> 30#include <errno.h> 31#include <fcntl.h> 32#include <stdlib.h> 33#include <string.h> 34#include <unistd.h> --- 26 unchanged lines hidden (view full) --- 61} 62 63/* 64 * Open a fifolog file or partition for reading or writing. 65 * 66 * Return value is NULL for success or a error description string to 67 * be augmented by errno if non-zero. 68 * | 27 */ 28 29#include <assert.h> 30#include <errno.h> 31#include <fcntl.h> 32#include <stdlib.h> 33#include <string.h> 34#include <unistd.h> --- 26 unchanged lines hidden (view full) --- 61} 62 63/* 64 * Open a fifolog file or partition for reading or writing. 65 * 66 * Return value is NULL for success or a error description string to 67 * be augmented by errno if non-zero. 68 * |
69 * The second function is just an error-handling wrapper around the | 69 * The second function is just an error-handling wrapper around the |
70 * first which, does the actual work. 71 */ 72 73static const char * 74fifolog_int_open_i(struct fifolog_file *f, const char *fname, int mode) 75{ 76 struct stat st; 77 unsigned u; --- 5 unchanged lines hidden (view full) --- 83 84 /* Determine initial record size guesstimate */ 85 i = ioctl(f->fd, DIOCGSECTORSIZE, &f->recsize); 86 if (i != 0 && errno != ENOTTY) 87 return ("ioctl(DIOCGSECTORSIZE) failed"); 88 89 if (i != 0) { 90 i = fstat(f->fd, &st); | 70 * first which, does the actual work. 71 */ 72 73static const char * 74fifolog_int_open_i(struct fifolog_file *f, const char *fname, int mode) 75{ 76 struct stat st; 77 unsigned u; --- 5 unchanged lines hidden (view full) --- 83 84 /* Determine initial record size guesstimate */ 85 i = ioctl(f->fd, DIOCGSECTORSIZE, &f->recsize); 86 if (i != 0 && errno != ENOTTY) 87 return ("ioctl(DIOCGSECTORSIZE) failed"); 88 89 if (i != 0) { 90 i = fstat(f->fd, &st); |
91 if (!S_ISREG(st.st_mode)) | 91 if (!S_ISREG(st.st_mode)) |
92 return ("Neither disk nor regular file"); 93 f->recsize = 512; 94 f->logsize = st.st_size; 95 } else if (f->recsize < 64) { 96 return ("Disk device sectorsize smaller than 64"); 97 } else { 98 i = ioctl(f->fd, DIOCGMEDIASIZE, &f->logsize); 99 if (i < 0 && errno != ENOTTY) --- 176 unchanged lines hidden --- | 92 return ("Neither disk nor regular file"); 93 f->recsize = 512; 94 f->logsize = st.st_size; 95 } else if (f->recsize < 64) { 96 return ("Disk device sectorsize smaller than 64"); 97 } else { 98 i = ioctl(f->fd, DIOCGMEDIASIZE, &f->logsize); 99 if (i < 0 && errno != ENOTTY) --- 176 unchanged lines hidden --- |