file_subs.c (c9a8d1f4ddce0e113129507ab55689b6e922f60d) | file_subs.c (46be34b90213ebd9037cb2c24aec0009d7f2f5c1) |
---|---|
1/*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Keith Muller of the University of California, San Diego. 8 * --- 26 unchanged lines hidden (view full) --- 35 * SUCH DAMAGE. 36 */ 37 38#ifndef lint 39#if 0 40static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93"; 41#endif 42static const char rcsid[] = | 1/*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Keith Muller of the University of California, San Diego. 8 * --- 26 unchanged lines hidden (view full) --- 35 * SUCH DAMAGE. 36 */ 37 38#ifndef lint 39#if 0 40static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93"; 41#endif 42static const char rcsid[] = |
43 "$Id$"; | 43 "$Id: file_subs.c,v 1.10 1998/05/15 06:27:39 charnier Exp $"; |
44#endif /* not lint */ 45 46#include <sys/types.h> 47#include <sys/time.h> 48#include <sys/stat.h> 49#include <unistd.h> 50#include <fcntl.h> 51#include <string.h> --- 37 unchanged lines hidden (view full) --- 89 int oerrno; 90 91 /* 92 * assume file doesn't exist, so just try to create it, most times this 93 * works. We have to take special handling when the file does exist. To 94 * detect this, we use O_EXCL. For example when trying to create a 95 * file and a character device or fifo exists with the same name, we 96 * can accidently open the device by mistake (or block waiting to open) | 44#endif /* not lint */ 45 46#include <sys/types.h> 47#include <sys/time.h> 48#include <sys/stat.h> 49#include <unistd.h> 50#include <fcntl.h> 51#include <string.h> --- 37 unchanged lines hidden (view full) --- 89 int oerrno; 90 91 /* 92 * assume file doesn't exist, so just try to create it, most times this 93 * works. We have to take special handling when the file does exist. To 94 * detect this, we use O_EXCL. For example when trying to create a 95 * file and a character device or fifo exists with the same name, we 96 * can accidently open the device by mistake (or block waiting to open) |
97 * If we find that the open has failed, then figure spend the effore to | 97 * If we find that the open has failed, then figure spend the effort to |
98 * figure out why. This strategy was found to have better average 99 * performance in common use than checking the file (and the path) 100 * first with lstat. 101 */ 102 file_mode = arcn->sb.st_mode & FILEBITS; 103 if ((fd = open(arcn->name, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 104 file_mode)) >= 0) 105 return(fd); --- 124 unchanged lines hidden (view full) --- 230cross_lnk(register ARCHD *arcn) 231#else 232int 233cross_lnk(arcn) 234 register ARCHD *arcn; 235#endif 236{ 237 /* | 98 * figure out why. This strategy was found to have better average 99 * performance in common use than checking the file (and the path) 100 * first with lstat. 101 */ 102 file_mode = arcn->sb.st_mode & FILEBITS; 103 if ((fd = open(arcn->name, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 104 file_mode)) >= 0) 105 return(fd); --- 124 unchanged lines hidden (view full) --- 230cross_lnk(register ARCHD *arcn) 231#else 232int 233cross_lnk(arcn) 234 register ARCHD *arcn; 235#endif 236{ 237 /* |
238 * try to make a link to orginal file (-l flag in copy mode). make sure | 238 * try to make a link to original file (-l flag in copy mode). make sure |
239 * we do not try to link to directories in case we are running as root 240 * (and it might succeed). 241 */ 242 if (arcn->type == PAX_DIR) 243 return(1); 244 return(mk_link(arcn->org_name, &(arcn->sb), arcn->name, 1)); 245} 246 --- 811 unchanged lines hidden --- | 239 * we do not try to link to directories in case we are running as root 240 * (and it might succeed). 241 */ 242 if (arcn->type == PAX_DIR) 243 return(1); 244 return(mk_link(arcn->org_name, &(arcn->sb), arcn->name, 1)); 245} 246 --- 811 unchanged lines hidden --- |