#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;
int fd;
/* Create the inode directory if we're starting for the first time */
- (void)afs_snprintf(filename, sizeof filename, "%s" OS_DIRSEP "%s", partition,
- INODEDIR);
+ snprintf(filename, sizeof filename, "%s" OS_DIRSEP "%s", partition,
+ INODEDIR);
mkdir(filename, 0700);
- (void)afs_snprintf(filename, sizeof filename, "%s" OS_DIRSEP "%s" OS_DIRSEP "README",
- partition, INODEDIR);
+ snprintf(filename, sizeof filename,
+ "%s" OS_DIRSEP "%s" OS_DIRSEP "README",
+ partition, INODEDIR);
fd = OS_OPEN(filename, O_WRONLY | O_CREAT | O_TRUNC, 0444);
if (fd != INVALID_FD) {
(void)OS_WRITE(fd, VICE_README, strlen(VICE_README));
int i;
*created = 0;
- afs_snprintf(tmp, 256, "%s" OS_DIRSEP "%s", name->n_drive, name->n_voldir);
+ snprintf(tmp, 256, "%s" OS_DIRSEP "%s", name->n_drive, name->n_voldir);
if (mkdir(tmp) < 0) {
if (errno != EEXIST)
char tmp[256];
int i;
- afs_snprintf(tmp, 256, "%s" OS_DIRSEP "%s", name->n_drive, name->n_voldir);
+ snprintf(tmp, 256, "%s" OS_DIRSEP "%s", name->n_drive, name->n_voldir);
path = tmp;
path += strlen(path);
}
if (count > 0) {
- FDH_REALLYCLOSE(fdP);
+ FDH_CLOSE(fdP);
IH_RELEASE(tmp);
return 0;
}
} else {
IHandle_t *th;
IH_INIT(th, ih->ih_dev, ih->ih_vid, ino);
- Log("Warning: Lost ref on ihandle dev %d vid %d ino %" AFS_INT64_FMT "\n",
+ Log("Warning: Lost ref on ihandle dev %d vid %d ino %lld\n",
th->ih_dev, th->ih_vid, (afs_int64)th->ih_ino);
IH_RELEASE(th);
fdP = IH_OPEN(h);
if (!fdP)
return EIO;
- afs_snprintf(path, sizeof(path), "%s-tmp", name.n_path);
+ snprintf(path, sizeof(path), "%s-tmp", name.n_path);
fd = OS_OPEN(path, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0);
if (fd == INVALID_FD) {
FDH_CLOSE(fdP);
}
FDH_SYNC(fdP);
FDH_UNLOCKFILE(fdP, offset);
- FDH_REALLYCLOSE(fdP);
+ FDH_CLOSE(fdP);
return col;
badGetFreeTag:
{
size_t n;
n = OS_WRITE(fp, info, sizeof(*info));
- return (n == 1) ? 0 : -2;
+ return (n == sizeof(*info)) ? 0 : -2;
}
/*
* Paranoia: check that the file is really the right size
*/
- if (OS_SIZE(inodeFile) * sizeof(struct ViceInodeInfo)) {
+ if (OS_SIZE(inodeFile) != ninodes * sizeof(struct ViceInodeInfo)) {
Log("Wrong size (%d instead of %lu) in inode file for %s\n",
(int) OS_SIZE(inodeFile),
(long unsigned int) ninodes * sizeof(struct ViceInodeInfo),
#else
if (*dp1->d_name == '.')
continue;
- afs_snprintf(path2, sizeof(path2), "%s" OS_DIRSEP "%s", name.n_path,
- dp1->d_name);
+ snprintf(path2, sizeof(path2), "%s" OS_DIRSEP "%s", name.n_path,
+ dp1->d_name);
dirp2 = opendir(path2);
if (dirp2) {
while ((dp2 = readdir(dirp2))) {
} else {
char path2[512];
/* Open this handle */
- (void)afs_snprintf(path2, sizeof(path2),
- "%s" OS_DIRSEP "%s", path1, dname);
+ snprintf(path2, sizeof(path2),
+ "%s" OS_DIRSEP "%s", path1, dname);
linkHandle->fd_fd = OS_OPEN(path2, Testing ? O_RDONLY : O_RDWR, 0666);
info.linkCount =
namei_GetLinkCount(linkHandle, (Inode) 0, 1, 1, Testing);
if (!judgeFun ||
(*judgeFun) (&info, singleVolumeNumber, rock)) {
- ret = 1;
- if ((*writeFun) (fp, &info, path1, dname) < 0) {
+ ret = (*writeFun) (fp, &info, path1, dname);
+ if (ret < 0) {
+ Log("_namei_examine_special: writeFun returned %d\n", ret);
ret = -1;
+ } else {
+ ret = 1;
}
}
if (!judgeFun ||
(*judgeFun) (&info, singleVolumeNumber, rock)) {
- ret = 1;
- if ((*writeFun) (fp, &info, path3, dname) < 0) {
+ ret = (*writeFun) (fp, &info, path3, dname);
+ if (ret < 0) {
+ Log("_namei_examine_reg: writeFun returned %d\n", ret);
ret = -1;
+ } else {
+ ret = 1;
}
}
#ifndef AFS_NT40_ENV /* This level missing on Windows */
/* Now we've got a next level subdir. */
- afs_snprintf(path2, sizeof(path2), "%s" OS_DIRSEP "%s", path1, dp1->d_name);
+ snprintf(path2, sizeof(path2), "%s" OS_DIRSEP "%s",
+ path1, dp1->d_name);
dirp2 = opendir(path2);
if (dirp2) {
while ((dp2 = readdir(dirp2))) {
continue;
/* Now we've got to the actual data */
- afs_snprintf(path3, sizeof(path3), "%s" OS_DIRSEP "%s", path2,
- dp2->d_name);
+ snprintf(path3, sizeof(path3), "%s" OS_DIRSEP "%s",
+ path2, dp2->d_name);
#else
/* Now we've got to the actual data */
- afs_snprintf(path3, sizeof(path3), "%s" OS_DIRSEP "%s", path1,
- dp1->d_name);
+ snprintf(path3, sizeof(path3), "%s" OS_DIRSEP "%s",
+ path1, dp1->d_name);
#endif
dirp3 = opendir(path3);
if (dirp3) {
FdHandle_t linkHandle;
char dirl;
- afs_snprintf(fpath, sizeof(fpath), "%s" OS_DIRSEP "%s", dpath, name);
+ snprintf(fpath, sizeof(fpath), "%s" OS_DIRSEP "%s", dpath, name);
dirH = FindFirstFileEx(fpath, FindExInfoStandard, &data,
FindExSearchNameMatch, NULL,
int parm, tag;
lb64_string_t check;
- afs_snprintf(fpath, sizeof(fpath), "%s" OS_DIRSEP "%s", dpath, name);
+ snprintf(fpath, sizeof(fpath), "%s" OS_DIRSEP "%s", dpath, name);
if (afs_stat(fpath, &status) < 0) {
return -1;
t_ih.ih_dev = ih->ih_dev;
t_ih.ih_vid = ih->ih_vid;
- (void)afs_snprintf(oldpath, sizeof oldpath, "%s" OS_DIRSEP "%s", dir_name,
- infoName);
+ snprintf(oldpath, sizeof oldpath, "%s" OS_DIRSEP "%s", dir_name,
+ infoName);
fd = OS_OPEN(oldpath, O_RDWR, 0);
if (fd == INVALID_FD) {
Log("1 namei_ConvertROtoRWvolume: could not open RO info file: %s\n",
t_ih.ih_ino = namei_MakeSpecIno(ih->ih_vid, VI_SMALLINDEX);
namei_HandleToName(&n, &t_ih);
- (void)afs_snprintf(newpath, sizeof newpath, "%s" OS_DIRSEP "%s", dir_name,
- smallName);
+ snprintf(newpath, sizeof newpath, "%s" OS_DIRSEP "%s", dir_name,
+ smallName);
fd = OS_OPEN(newpath, O_RDWR, 0);
if (fd == INVALID_FD) {
Log("1 namei_ConvertROtoRWvolume: could not open SmallIndex file: %s\n", newpath);
t_ih.ih_ino = namei_MakeSpecIno(ih->ih_vid, VI_LARGEINDEX);
namei_HandleToName(&n, &t_ih);
- (void)afs_snprintf(newpath, sizeof newpath, "%s" OS_DIRSEP "%s", dir_name,
- largeName);
+ snprintf(newpath, sizeof newpath, "%s" OS_DIRSEP "%s", dir_name,
+ largeName);
fd = OS_OPEN(newpath, O_RDWR, 0);
if (fd == INVALID_FD) {
Log("1 namei_ConvertROtoRWvolume: could not open LargeIndex file: %s\n", newpath);
if (!s)
s = result;
- (void)afs_snprintf(s, sizeof(afs_ino_str_t), "%" AFS_UINT64_FMT, (afs_uintmax_t) ino);
+ snprintf(s, sizeof(afs_ino_str_t), "%llu", (afs_uintmax_t) ino);
return s;
}