equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * CDDL HEADER START |
2 * CDDL HEADER START |
3 * |
3 * |
4 * The contents of this file are subject to the terms of the |
4 * The contents of this file are subject to the terms of the |
5 * Common Development and Distribution License, Version 1.0 only |
5 * Common Development and Distribution License (the "License"). |
6 * (the "License"). You may not use this file except in compliance |
6 * You may not use this file except in compliance with the License. |
7 * with the License. |
|
8 * |
7 * |
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
10 * or http://www.opensolaris.org/os/licensing. |
9 * or http://www.opensolaris.org/os/licensing. |
11 * See the License for the specific language governing permissions |
10 * See the License for the specific language governing permissions |
12 * and limitations under the License. |
11 * and limitations under the License. |
16 * If applicable, add the following below this CDDL HEADER, with the |
15 * If applicable, add the following below this CDDL HEADER, with the |
17 * fields enclosed by brackets "[]" replaced with your own identifying |
16 * fields enclosed by brackets "[]" replaced with your own identifying |
18 * information: Portions Copyright [yyyy] [name of copyright owner] |
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
19 * |
18 * |
20 * CDDL HEADER END |
19 * CDDL HEADER END |
21 * |
20 */ |
22 * Copyright 2001 Sun Microsystems, Inc. All rights reserved. |
21 |
|
22 /* |
|
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
23 * Use is subject to license terms. |
24 * Use is subject to license terms. |
24 */ |
25 */ |
25 |
26 |
26 /* |
27 /* |
27 * where.c - get full pathname including host: |
28 * where.c - get full pathname including host: |
28 */ |
29 */ |
29 |
30 |
30 #pragma ident "%Z%%M% %I% %E% SMI" |
31 #pragma ident "%Z%%M% %I% %E% SMI" |
31 |
|
32 |
32 |
33 #include <netdb.h> |
33 #include <netdb.h> |
34 #include <stdio.h> |
34 #include <stdio.h> |
35 #include <stdlib.h> |
35 #include <stdlib.h> |
36 #include <string.h> |
36 #include <string.h> |
43 |
43 |
44 #include <sys/mnttab.h> |
44 #include <sys/mnttab.h> |
45 #include <sys/param.h> |
45 #include <sys/param.h> |
46 #include <sys/stat.h> |
46 #include <sys/stat.h> |
47 |
47 |
|
48 #include <sharefs/share.h> |
48 #include "sharetab.h" |
49 #include "sharetab.h" |
49 |
50 |
50 extern FILE *setmntent(); |
51 extern FILE *setmntent(); |
51 |
52 |
52 FILE *setsharetab(); |
53 FILE *setsharetab(); |
258 |
259 |
259 FILE |
260 FILE |
260 *setsharetab() |
261 *setsharetab() |
261 { |
262 { |
262 FILE *f; |
263 FILE *f; |
263 int fd; |
264 |
264 |
265 f = fopen(SHARETAB, "r"); |
265 /* |
|
266 * Create the tab file if it does not exist already |
|
267 */ |
|
268 if (access(SHARETAB, F_OK) < 0) { |
|
269 fd = open(SHARETAB, O_CREAT, 0644); |
|
270 close(fd); |
|
271 } |
|
272 if (access(SHARETAB, W_OK) == 0) { |
|
273 f = fopen(SHARETAB, "r+"); |
|
274 } else { |
|
275 f = fopen(SHARETAB, "r"); |
|
276 } |
|
277 if (f == NULL) { |
266 if (f == NULL) { |
278 return (NULL); |
267 return (NULL); |
279 } |
268 } |
280 if (lockf(fileno(f), F_LOCK, 0L) < 0) { |
269 |
281 (void) fclose(f); |
|
282 return (NULL); |
|
283 } |
|
284 return (f); |
270 return (f); |
285 } |
271 } |
286 |
272 |
287 |
273 |
288 void |
274 void |