#include <roken.h>
+
#ifdef AFS_NAMEI_ENV
-#include <stdio.h>
-#include <stdlib.h>
-#ifndef AFS_NT40_ENV
-#include <unistd.h>
-#else
+
+#ifdef HAVE_SYS_FILE_H
+# include <sys/file.h>
+#endif
+
+#ifdef AFS_NT40_ENV
#define DELETE_ZLC
-#include <io.h>
#include <windows.h>
#include <winnt.h>
#include <winbase.h>
-#include <winsock2.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#ifdef AFS_NT40_ENV
#include <direct.h>
-#else
-#include <sys/file.h>
-#include <sys/param.h>
#endif
-#include <dirent.h>
-#include <afs/afs_assert.h>
-#include <string.h>
+
#include <lock.h>
#include <afs/afsutil.h>
#include <lwp.h>
#include "volume_inline.h"
#include "common.h"
#include <afs/errors.h>
+
#ifdef AFS_NT40_ENV
#include <afs/errmap_nt.h>
#endif
#include <vol/vol-salvage.h>
#endif
-#if !defined(HAVE_FLOCK) && !defined(AFS_NT40_ENV)
-#include <fcntl.h>
-
-/*
- * This function emulates a subset of flock()
- */
-int
-emul_flock(int fd, int cmd)
-{ struct flock f;
-
- memset(&f, 0, sizeof (f));
-
- if (cmd & LOCK_UN)
- f.l_type = F_UNLCK;
- if (cmd & LOCK_SH)
- f.l_type = F_RDLCK;
- if (cmd & LOCK_EX)
- f.l_type = F_WRLCK;
-
- return fcntl(fd, (cmd & LOCK_NB) ? F_SETLK : F_SETLKW, &f);
-}
-
-#define flock(f,c) emul_flock(f,c)
-#endif
-
int Testing=0;
p++;
for (tag = 0; tag < NAMEI_MAXVOLS; tag++) {
*p = *int_to_base32(str1, tag);
- fd = OS_OPEN((char *)&name.n_path, O_CREAT | O_RDWR | O_TRUNC | O_EXCL, 0666);
+ fd = OS_OPEN((char *)&name.n_path, O_CREAT | O_RDWR | O_EXCL, 0666);
if (fd == INVALID_FD) {
if (errno == ENOTDIR || errno == ENOENT) {
if (namei_CreateDataDirectories(&name, &created_dir) == 0)
- fd = OS_OPEN((char *)&name.n_path, O_CREAT | O_RDWR | O_TRUNC | O_EXCL, 0666);
+ fd = OS_OPEN((char *)&name.n_path, O_CREAT | O_RDWR | O_EXCL, 0666);
}
}
}
namei_HandleToName(&name, &tmp);
- fd = OS_OPEN(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
+ fd = OS_OPEN(name.n_path, O_CREAT | O_EXCL | O_RDWR, 0);
if (fd == INVALID_FD) {
if (errno == ENOTDIR || errno == ENOENT) {
if (namei_CreateDataDirectories(&name, &created_dir) < 0)
goto bad;
- fd = OS_OPEN(name.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR,
+ fd = OS_OPEN(name.n_path, O_CREAT | O_EXCL | O_RDWR,
0);
if (fd == INVALID_FD)
goto bad;
}
if (count > 0) {
- FDH_REALLYCLOSE(fdP);
+ FDH_CLOSE(fdP);
IH_RELEASE(tmp);
return 0;
}
if (!fdP)
return EIO;
snprintf(path, sizeof(path), "%s-tmp", name.n_path);
- fd = OS_OPEN(path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
+ fd = OS_OPEN(path, O_CREAT | O_EXCL | O_RDWR, 0);
if (fd == INVALID_FD) {
FDH_CLOSE(fdP);
return EIO;
}
FDH_SYNC(fdP);
FDH_UNLOCKFILE(fdP, offset);
- FDH_REALLYCLOSE(fdP);
+ FDH_CLOSE(fdP);
return col;
badGetFreeTag:
}
t_ih.ih_ino = namei_MakeSpecIno(ih->ih_vid, VI_VOLINFO);
namei_HandleToName(&n, &t_ih);
- fd2 = OS_OPEN(n.n_path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
+ fd2 = OS_OPEN(n.n_path, O_CREAT | O_EXCL | O_RDWR, 0);
if (fd2 == INVALID_FD) {
Log("1 namei_ConvertROtoRWvolume: could not create RW info file: %s\n", n.n_path);
OS_CLOSE(fd);