Changeset 312 for branches/samba-3.0/source/client/umount.cifs.c
- Timestamp:
- Aug 5, 2009, 6:34:45 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.0/source/client/umount.cifs.c
r165 r312 35 35 #include <string.h> 36 36 #include <mntent.h> 37 #include <limits.h> 37 38 #include "mount.h" 38 39 … … 233 234 } 234 235 236 /* Make a canonical pathname from PATH. Returns a freshly malloced string. 237 It is up the *caller* to ensure that the PATH is sensible. i.e. 238 canonicalize ("/dev/fd0/.") returns "/dev/fd0" even though ``/dev/fd0/.'' 239 is not a legal pathname for ``/dev/fd0'' Anything we cannot parse 240 we return unmodified. */ 241 static char * 242 canonicalize(char *path) 243 { 244 char *canonical = malloc (PATH_MAX + 1); 245 246 if (!canonical) { 247 fprintf(stderr, "Error! Not enough memory!\n"); 248 return NULL; 249 } 250 251 if (strlen(path) > PATH_MAX) { 252 fprintf(stderr, "Mount point string too long\n"); 253 return NULL; 254 } 255 256 if (path == NULL) 257 return NULL; 258 259 if (realpath (path, canonical)) 260 return canonical; 261 262 strncpy (canonical, path, PATH_MAX); 263 canonical[PATH_MAX] = '\0'; 264 return canonical; 265 } 266 235 267 int main(int argc, char ** argv) 236 268 { … … 306 338 argc -= optind; 307 339 308 mountpoint = argv[0];340 mountpoint = canonicalize(argv[0]); 309 341 310 342 if((argc < 1) || (argv[0] == NULL)) {
Note:
See TracChangeset
for help on using the changeset viewer.