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