open.c (3557869e5f4882aac0d600d2a8416e71737feb51) | open.c (313724bab940c1844fda3d797cf88cd46780e62a) |
---|---|
1/* $NetBSD: open.c,v 1.16 1997/01/28 09:41:03 pk Exp $ */ 2 3/*- 4 * Copyright (c) 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * The Mach Operating System project at Carnegie-Mellon University. --- 82 unchanged lines hidden (view full) --- 91int 92open(const char *fname, int mode) 93{ 94 struct fs_ops *fs; 95 struct open_file *f; 96 int fd, i, error, besterror; 97 const char *file; 98 | 1/* $NetBSD: open.c,v 1.16 1997/01/28 09:41:03 pk Exp $ */ 2 3/*- 4 * Copyright (c) 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * The Mach Operating System project at Carnegie-Mellon University. --- 82 unchanged lines hidden (view full) --- 91int 92open(const char *fname, int mode) 93{ 94 struct fs_ops *fs; 95 struct open_file *f; 96 int fd, i, error, besterror; 97 const char *file; 98 |
99 TSENTER(); 100 |
|
99 if ((fd = o_gethandle()) == -1) { 100 errno = EMFILE; 101 return (-1); 102 } 103 104 f = &files[fd]; 105 f->f_flags = mode + 1; 106 f->f_dev = NULL; --- 14 unchanged lines hidden (view full) --- 121 if (error || 122 (((f->f_flags & F_NODEV) == 0) && f->f_dev == NULL)) 123 goto err; 124 125 /* see if we opened a raw device; otherwise, 'file' is the file name. */ 126 if (file == NULL || *file == '\0') { 127 f->f_flags |= F_RAW; 128 f->f_rabuf = NULL; | 101 if ((fd = o_gethandle()) == -1) { 102 errno = EMFILE; 103 return (-1); 104 } 105 106 f = &files[fd]; 107 f->f_flags = mode + 1; 108 f->f_dev = NULL; --- 14 unchanged lines hidden (view full) --- 123 if (error || 124 (((f->f_flags & F_NODEV) == 0) && f->f_dev == NULL)) 125 goto err; 126 127 /* see if we opened a raw device; otherwise, 'file' is the file name. */ 128 if (file == NULL || *file == '\0') { 129 f->f_flags |= F_RAW; 130 f->f_rabuf = NULL; |
131 TSEXIT(); |
|
129 return (fd); 130 } 131 132 /* pass file name to the different filesystem open routines */ 133 besterror = ENOENT; 134 for (i = 0; file_system[i] != NULL; i++) { 135 fs = file_system[i]; 136 error = (fs->fo_open)(file, f); --- 7 unchanged lines hidden (view full) --- 144 if ((f->f_flags & F_NODEV) == 0 && f->f_dev != NULL) 145 f->f_dev->dv_close(f); 146 if (error) 147 devclose(f); 148 149err: 150 f->f_flags = 0; 151 errno = error; | 132 return (fd); 133 } 134 135 /* pass file name to the different filesystem open routines */ 136 besterror = ENOENT; 137 for (i = 0; file_system[i] != NULL; i++) { 138 fs = file_system[i]; 139 error = (fs->fo_open)(file, f); --- 7 unchanged lines hidden (view full) --- 147 if ((f->f_flags & F_NODEV) == 0 && f->f_dev != NULL) 148 f->f_dev->dv_close(f); 149 if (error) 150 devclose(f); 151 152err: 153 f->f_flags = 0; 154 errno = error; |
155 TSEXIT(); |
|
152 return (-1); 153 154ok: 155 f->f_ops = fs; 156 o_rainit(f); | 156 return (-1); 157 158ok: 159 f->f_ops = fs; 160 o_rainit(f); |
161 TSEXIT(); |
|
157 return (fd); 158} | 162 return (fd); 163} |