mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
afsio: process windows file paths consistently
Windows file paths can use either '\' or '/' as a path separator. libafscp on the other hand requires '/' and argv[0] will always use '\'. Introduce a new function ConvertAFSPath() which converts the input path to '/' and converts \\afs to /afs. A future commit should access the registry and make use of the NetbiosName and MountRoot values to perform the conversion correctly. Change-Id: I14f5f45234ec4beab58751783a25206b3e7eff45 Reviewed-on: http://gerrit.openafs.org/8430 Reviewed-by: Derrick Brashear <shadow@your-file-system.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com> Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
This commit is contained in:
parent
be50ea11fe
commit
0bef3159d3
@ -187,6 +187,23 @@ summarizeMD5(char *fname)
|
||||
htonl(md5int[1]), htonl(md5int[2]), htonl(md5int[3]), p);
|
||||
} /* summarizeMD5 */
|
||||
|
||||
#ifdef AFS_NT40_ENV
|
||||
static void
|
||||
ConvertAFSPath(char **fnp)
|
||||
{
|
||||
char *p;
|
||||
|
||||
for (p = *fnp; *p; p++) {
|
||||
if (*p == '\\')
|
||||
*p = '/';
|
||||
}
|
||||
|
||||
p = *fnp;
|
||||
if (p[0] == '/' && p[1] == '/')
|
||||
*fnp = p+1;
|
||||
}
|
||||
#endif /* AFS_NT40_ENV */
|
||||
|
||||
/*!
|
||||
* parses all command-line arguments
|
||||
*
|
||||
@ -232,11 +249,15 @@ CmdProlog(struct cmd_syndesc *as, char **cellp, char **realmp,
|
||||
else if (strcmp(pdp->name, "-cell") == 0) {
|
||||
cellGiven = 1; /* global */
|
||||
*cellp = pdp->items->data;
|
||||
} else if ( (strcmp(pdp->name, "-file") == 0) ||
|
||||
(strcmp(pdp->name, "-fid") == 0) ||
|
||||
(strcmp(pdp->name, "-vnode") == 0) )
|
||||
} else if ( strcmp(pdp->name, "-file") == 0) {
|
||||
*fnp = pdp->items->data;
|
||||
else if (strcmp(pdp->name, "-force") == 0)
|
||||
#ifdef AFS_NT40_ENV
|
||||
ConvertAFSPath(fnp);
|
||||
#endif /* AFS_NT40_ENV */
|
||||
} else if ( (strcmp(pdp->name, "-fid") == 0) ||
|
||||
(strcmp(pdp->name, "-vnode") == 0) ) {
|
||||
*fnp = pdp->items->data;
|
||||
} else if (strcmp(pdp->name, "-force") == 0)
|
||||
force = 1; /* global */
|
||||
else if (strcmp(pdp->name, "-synthesize") == 0)
|
||||
*slp = pdp->items->data;
|
||||
@ -256,9 +277,18 @@ main(int argc, char **argv)
|
||||
{
|
||||
struct cmd_syndesc *ts;
|
||||
char baseName[AFSNAMEMAX];
|
||||
int code;
|
||||
|
||||
/* try to get only the base name of this executable for use in logs */
|
||||
if (BreakUpPath(argv[0], NULL, baseName, AFSNAMEMAX) > 0)
|
||||
#ifdef AFS_NT40_ENV
|
||||
char *p = strdup(argv[0]);
|
||||
ConvertAFSPath(&p);
|
||||
code = BreakUpPath(p, NULL, baseName, AFSNAMEMAX);
|
||||
free(p);
|
||||
#else
|
||||
code = BreakUpPath(argv[0], NULL, baseName, AFSNAMEMAX);
|
||||
#endif
|
||||
if (code > 0)
|
||||
strlcpy(pnp, baseName, AFSNAMEMAX);
|
||||
else
|
||||
strlcpy(pnp, argv[0], AFSPATHMAX);
|
||||
@ -551,11 +581,7 @@ BreakUpPath(char *fullPath, char *dirName, char *baseName, size_t baseNameSize)
|
||||
/* would be pointless to continue -- must be error in call */
|
||||
return code;
|
||||
}
|
||||
#ifdef AFS_NT40_ENV
|
||||
lastSlash = strrchr(fullPath, '\\');
|
||||
#else
|
||||
lastSlash = strrchr(fullPath, '/');
|
||||
#endif
|
||||
if (lastSlash != NULL) {
|
||||
/* then lastSlash points to the last path separator in fullPath */
|
||||
if (useDirName) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user