diff --git a/src/WINNT/client_exp/gui2fs.cpp b/src/WINNT/client_exp/gui2fs.cpp index 02a920cc73..f45a6b424a 100644 --- a/src/WINNT/client_exp/gui2fs.cpp +++ b/src/WINNT/client_exp/gui2fs.cpp @@ -1226,6 +1226,39 @@ BOOL IsSymlink(const char * true_name) } +BOOL IsMountPoint(const char * name) +{ + register LONG code = 0; + struct ViceIoctl blob; + char tbuffer[1024]; + char lsbuffer[1024]; + register char *tp; + char szCurItem[1024]; + strcpy(szCurItem, name); + + tp = (char *)strrchr(szCurItem, '\\'); + if (tp) { + strncpy(tbuffer, szCurItem, code = tp - szCurItem + 1); /* the dir name */ + tbuffer[code] = 0; + tp++; /* skip the slash */ + } else { + fs_ExtractDriveLetter(szCurItem, tbuffer); + strcat(tbuffer, "."); + tp = szCurItem; + fs_StripDriveLetter(tp, tp, 0); + } + + blob.in = tp; + blob.in_size = strlen(tp)+1; + blob.out = lsbuffer; + blob.out_size = sizeof(lsbuffer); + + code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0); + + return (code==0); +} + + /* * Delete AFS mount points. Variables are used as follows: * tbuffer: Set to point to the null-terminated directory name of the mount point @@ -1247,28 +1280,7 @@ BOOL RemoveMount(CStringArray& files) HOURGLASS hourglass; for (int i = 0; i < files.GetSize(); i++) { - char szCurItem[1024]; - strcpy(szCurItem, files[i]); - - tp = (char *)strrchr(szCurItem, '\\'); - if (tp) { - strncpy(tbuffer, szCurItem, code = tp - szCurItem + 1); /* the dir name */ - tbuffer[code] = 0; - tp++; /* skip the slash */ - } else { - fs_ExtractDriveLetter(szCurItem, tbuffer); - strcat(tbuffer, "."); - tp = szCurItem; - fs_StripDriveLetter(tp, tp, 0); - } - - blob.in = tp; - blob.in_size = strlen(tp)+1; - blob.out = lsbuffer; - blob.out_size = sizeof(lsbuffer); - - code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0); - if (code) { + if (!IsMountPoint(files[i])) { error = TRUE; if (errno == EINVAL) results.Add(GetMessageString(IDS_NOT_MOUNT_POINT_ERROR, StripPath(files[i]))); diff --git a/src/WINNT/client_exp/gui2fs.h b/src/WINNT/client_exp/gui2fs.h index 494217223a..b0c5e9e7f9 100644 --- a/src/WINNT/client_exp/gui2fs.h +++ b/src/WINNT/client_exp/gui2fs.h @@ -39,6 +39,7 @@ int GetCellName(char *baseNamep, struct afsconf_cell *infop); long fs_StripDriveLetter(const char *inPathp, char *outPathp, long outSize); long fs_ExtractDriveLetter(const char *inPathp, char *outPathp); BOOL IsSymlink(const char * true_name); +BOOL IsMountPoint(const char * name); UINT MakeSymbolicLink(const char *,const char *); void ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath); #endif //__GUI2FS_H__ diff --git a/src/WINNT/client_exp/shell_ext.cpp b/src/WINNT/client_exp/shell_ext.cpp index c377793b7e..7324561ef3 100644 --- a/src/WINNT/client_exp/shell_ext.cpp +++ b/src/WINNT/client_exp/shell_ext.cpp @@ -224,9 +224,16 @@ STDMETHODIMP CShellExt::XMenuExt::QueryContextMenu(HMENU hMenu,UINT indexMenu, // Mount Point submenu of the AFS submenu HMENU hMountPointMenu = CreatePopupMenu(); int indexMountPointMenu = 0; - ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_SHOW, GetMessageString(IDS_MP_SHOW_ITEM)); - ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_REMOVE, GetMessageString(IDS_MP_REMOVE_ITEM)); - ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_MAKE, GetMessageString(IDS_MP_MAKE_ITEM)); + int nMountPointSelected = MF_GRAYED; + for (int n = pThis->m_astrFileNames.GetSize() - 1 ; n >= 0; n--) { + if ( IsMountPoint(pThis->m_astrFileNames[n]) ) { + nMountPointSelected = MF_ENABLED; + break; + } + } + ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_SHOW, GetMessageString(IDS_MP_SHOW_ITEM)); + ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION | nMountPointSelected, idCmdFirst + IDM_MOUNTPOINT_REMOVE, GetMessageString(IDS_MP_REMOVE_ITEM)); + ::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_MAKE, GetMessageString(IDS_MP_MAKE_ITEM)); ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hMountPointMenu, GetMessageString(IDS_MOUNT_POINT_ITEM)); ::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_FLUSH, GetMessageString(IDS_FLUSH_FILE_DIR_ITEM));