bt_open.c (55837) | bt_open.c (56698) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Mike Olson. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * | 1/*- 2 * Copyright (c) 1990, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Mike Olson. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * |
36 * $FreeBSD: head/lib/libc/db/btree/bt_open.c 55837 2000-01-12 09:23:48Z jasone $ | 36 * $FreeBSD: head/lib/libc/db/btree/bt_open.c 56698 2000-01-27 23:07:25Z jasone $ |
37 */ 38 39#if defined(LIBC_SCCS) && !defined(lint) 40static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94"; 41#endif /* LIBC_SCCS and not lint */ 42 43/* 44 * Implementation of btree access method for 4.4BSD. --- 153 unchanged lines hidden (view full) --- 198 break; 199 case O_RDWR: 200 break; 201 case O_WRONLY: 202 default: 203 goto einval; 204 } 205 | 37 */ 38 39#if defined(LIBC_SCCS) && !defined(lint) 40static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94"; 41#endif /* LIBC_SCCS and not lint */ 42 43/* 44 * Implementation of btree access method for 4.4BSD. --- 153 unchanged lines hidden (view full) --- 198 break; 199 case O_RDWR: 200 break; 201 case O_WRONLY: 202 default: 203 goto einval; 204 } 205 |
206 if ((t->bt_fd = _libc_open(fname, flags, mode)) < 0) | 206 if ((t->bt_fd = _open(fname, flags, mode)) < 0) |
207 goto err; 208 209 } else { 210 if ((flags & O_ACCMODE) != O_RDWR) 211 goto einval; 212 if ((t->bt_fd = tmp()) == -1) 213 goto err; 214 F_SET(t, B_INMEM); 215 } 216 | 207 goto err; 208 209 } else { 210 if ((flags & O_ACCMODE) != O_RDWR) 211 goto einval; 212 if ((t->bt_fd = tmp()) == -1) 213 goto err; 214 F_SET(t, B_INMEM); 215 } 216 |
217 if (_libc_fcntl(t->bt_fd, F_SETFD, 1) == -1) | 217 if (_fcntl(t->bt_fd, F_SETFD, 1) == -1) |
218 goto err; 219 220 if (fstat(t->bt_fd, &sb)) 221 goto err; 222 if (sb.st_size) { | 218 goto err; 219 220 if (fstat(t->bt_fd, &sb)) 221 goto err; 222 if (sb.st_size) { |
223 if ((nr = _libc_read(t->bt_fd, &m, sizeof(BTMETA))) < 0) | 223 if ((nr = _read(t->bt_fd, &m, sizeof(BTMETA))) < 0) |
224 goto err; 225 if (nr != sizeof(BTMETA)) 226 goto eftype; 227 228 /* 229 * Read in the meta-data. This can change the notion of what 230 * the lorder, page size and flags are, and, when the page size 231 * changes, the cachesize value can change too. If the user --- 99 unchanged lines hidden (view full) --- 331 332eftype: errno = EFTYPE; 333 goto err; 334 335err: if (t) { 336 if (t->bt_dbp) 337 free(t->bt_dbp); 338 if (t->bt_fd != -1) | 224 goto err; 225 if (nr != sizeof(BTMETA)) 226 goto eftype; 227 228 /* 229 * Read in the meta-data. This can change the notion of what 230 * the lorder, page size and flags are, and, when the page size 231 * changes, the cachesize value can change too. If the user --- 99 unchanged lines hidden (view full) --- 331 332eftype: errno = EFTYPE; 333 goto err; 334 335err: if (t) { 336 if (t->bt_dbp) 337 free(t->bt_dbp); 338 if (t->bt_fd != -1) |
339 (void)_libc_close(t->bt_fd); | 339 (void)_close(t->bt_fd); |
340 free(t); 341 } 342 return (NULL); 343} 344 345/* 346 * NROOT -- Create the root of a new tree. 347 * --- 100 unchanged lines hidden --- | 340 free(t); 341 } 342 return (NULL); 343} 344 345/* 346 * NROOT -- Create the root of a new tree. 347 * --- 100 unchanged lines hidden --- |