mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 15:30:14 +00:00
windows-vol-ntops-20060904
add nt_SetNonZLC()
This commit is contained in:
parent
5a57fce902
commit
474df74c88
@ -41,6 +41,8 @@ RCSID
|
||||
|
||||
#define BASEFILEATTRIBUTE FILE_ATTRIBUTE_NORMAL
|
||||
|
||||
int Testing = 0;
|
||||
|
||||
static void AddToZLCDeleteList(char dir, char *name);
|
||||
|
||||
/* nt_unlink - unlink a case sensitive name.
|
||||
@ -837,13 +839,17 @@ nt_GetLCOffsetAndIndexFromIno(Inode ino, int *offset, int *index)
|
||||
* If lockit is set, lock the file and leave it locked upon a successful
|
||||
* return.
|
||||
*/
|
||||
int
|
||||
nt_GetLinkCount(FdHandle_t * h, Inode ino, int lockit)
|
||||
static int
|
||||
nt_GetLinkCountInternal(FdHandle_t * h, Inode ino, int lockit, int fixup)
|
||||
{
|
||||
unsigned short row = 0;
|
||||
int junk;
|
||||
DWORD bytesRead, bytesWritten;
|
||||
int offset, index;
|
||||
|
||||
/* there's no linktable yet. the salvager will create one later */
|
||||
if (h->fd_fd == INVALID_HANDLE_VALUE && fixup)
|
||||
return 1;
|
||||
|
||||
nt_GetLCOffsetAndIndexFromIno(ino, &offset, &index);
|
||||
|
||||
if (lockit) {
|
||||
@ -854,10 +860,25 @@ nt_GetLinkCount(FdHandle_t * h, Inode ino, int lockit)
|
||||
if (!SetFilePointer(h->fd_fd, (LONG) offset, NULL, FILE_BEGIN))
|
||||
goto bad_getLinkByte;
|
||||
|
||||
if (!ReadFile(h->fd_fd, (void *)&row, 2, &junk, NULL)) {
|
||||
if (!ReadFile(h->fd_fd, (void *)&row, 2, &bytesRead, NULL))
|
||||
goto bad_getLinkByte;
|
||||
|
||||
if (bytesRead == 0 && fixup) {
|
||||
LARGE_INTEGER size;
|
||||
|
||||
if (!GetFileSizeEx(h->fd_fd, &size) || size.QuadPart >= offset+sizeof(row))
|
||||
goto bad_getLinkByte;
|
||||
FDH_TRUNC(h, offset+sizeof(row));
|
||||
row = 1 << index;
|
||||
rewrite:
|
||||
WriteFile(h->fd_fd, (char *)&row, sizeof(row), &bytesWritten, NULL);
|
||||
}
|
||||
|
||||
if (fixup && !((row >> index) & NT_TAGMASK)) {
|
||||
row |= 1<<index;
|
||||
goto rewrite;
|
||||
}
|
||||
|
||||
return (int)((row >> index) & NT_TAGMASK);
|
||||
|
||||
bad_getLinkByte:
|
||||
@ -866,7 +887,17 @@ nt_GetLinkCount(FdHandle_t * h, Inode ino, int lockit)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
nt_GetLinkCount(FdHandle_t * h, Inode ino, int lockit)
|
||||
{
|
||||
return nt_GetLinkCountInternal(h, ino, lockit, 0);
|
||||
}
|
||||
|
||||
void
|
||||
nt_SetNonZLC(FdHandle_t * h, Inode ino)
|
||||
{
|
||||
(void)nt_GetLinkCountInternal(h, ino, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
/* nt_SetLinkCount
|
||||
@ -878,7 +909,7 @@ nt_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked)
|
||||
{
|
||||
int offset, index;
|
||||
unsigned short row;
|
||||
int junk;
|
||||
DWORD bytesRead, bytesWritten;
|
||||
int code = -1;
|
||||
|
||||
nt_GetLCOffsetAndIndexFromIno(ino, &offset, &index);
|
||||
@ -896,16 +927,16 @@ nt_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked)
|
||||
}
|
||||
|
||||
|
||||
if (!ReadFile(h->fd_fd, (void *)&row, 2, &junk, NULL)) {
|
||||
if (!ReadFile(h->fd_fd, (void *)&row, 2, &bytesRead, NULL)) {
|
||||
errno = nterr_nt2unix(GetLastError(), EBADF);
|
||||
goto bad_SetLinkCount;
|
||||
}
|
||||
if (junk == 0)
|
||||
if (bytesRead == 0)
|
||||
row = 0;
|
||||
|
||||
junk = 7 << index;
|
||||
bytesRead = 7 << index;
|
||||
count <<= index;
|
||||
row &= (unsigned short)~junk;
|
||||
row &= (unsigned short)~bytesRead;
|
||||
row |= (unsigned short)count;
|
||||
|
||||
if (!SetFilePointer(h->fd_fd, (LONG) offset, NULL, FILE_BEGIN)) {
|
||||
@ -913,7 +944,7 @@ nt_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked)
|
||||
goto bad_SetLinkCount;
|
||||
}
|
||||
|
||||
if (!WriteFile(h->fd_fd, (void *)&row, 2, &junk, NULL)) {
|
||||
if (!WriteFile(h->fd_fd, (void *)&row, 2, &bytesWritten, NULL)) {
|
||||
errno = nterr_nt2unix(GetLastError(), EBADF);
|
||||
goto bad_SetLinkCount;
|
||||
}
|
||||
|
@ -60,4 +60,6 @@ int ListViceInodes(char *devname, char *mountedOn, char *resultFile,
|
||||
int nt_HandleToName(char *name, IHandle_t * h);
|
||||
char *nt_HandleToVolDir(char *name, IHandle_t * h);
|
||||
|
||||
extern int Testing;
|
||||
|
||||
#endif /* _NTOPS_H_ */
|
||||
|
@ -1458,11 +1458,20 @@ DoSalvageVolumeGroup(register struct InodeSummary *isp, int nVols)
|
||||
fdP = IH_OPEN(VGLinkH);
|
||||
/* Sync fake 1 link counts to the link table, now that it exists */
|
||||
if (fdP) {
|
||||
#ifdef AFS_NT40_ENV
|
||||
nt_SetNonZLC(fdP, ino);
|
||||
#else
|
||||
namei_SetNonZLC(fdP, ino);
|
||||
#endif
|
||||
for (i = 0; i < nVols; i++) {
|
||||
ip = allInodes + isp[i].index;
|
||||
for (j = isp[i].nSpecialInodes; j < isp[i].nInodes; j++)
|
||||
namei_SetNonZLC(fdP, ip[j].inodeNumber);
|
||||
for (j = isp[i].nSpecialInodes; j < isp[i].nInodes; j++) {
|
||||
#ifdef AFS_NT40_ENV
|
||||
nt_SetNonZLC(fdP, ip[j].inodeNumber);
|
||||
#else
|
||||
namei_SetNonZLC(fdP, ip[j].inodeNumber);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user