disk.c (c32dde3166922f55927764464d13f1bc9640f5f6) | disk.c (17276525fa1a28028f7ca423f365d5081cbe9a97) |
---|---|
1/*- 2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 3 * Copyright (c) 2012 Andrey V. Elsukov <ae@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 399 unchanged lines hidden (view full) --- 408 } 409 if (dev->d_partition > D_PARTNONE) 410 cp += sprintf(cp, "%c", dev->d_partition + 'a'); 411 strcat(cp, ":"); 412 return (buf); 413} 414 415int | 1/*- 2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 3 * Copyright (c) 2012 Andrey V. Elsukov <ae@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 399 unchanged lines hidden (view full) --- 408 } 409 if (dev->d_partition > D_PARTNONE) 410 cp += sprintf(cp, "%c", dev->d_partition + 'a'); 411 strcat(cp, ":"); 412 return (buf); 413} 414 415int |
416disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path) | 416disk_parsedev(struct devdesc **idev, const char *devspec, const char **path) |
417{ 418 int unit, slice, partition; 419 const char *np; 420 char *cp; | 417{ 418 int unit, slice, partition; 419 const char *np; 420 char *cp; |
421 struct disk_devdesc *dev; |
|
421 422 np = devspec; 423 unit = -1; 424 /* 425 * If there is path/file info after the device info, then any missing 426 * slice or partition info should be considered a request to search for 427 * an appropriate partition. Otherwise we want to open the raw device 428 * itself and not try to fill in missing info by searching. --- 36 unchanged lines hidden (view full) --- 465 return (EPART); 466 cp++; 467 } 468 } else 469 return (EINVAL); 470 471 if (*cp != '\0' && *cp != ':') 472 return (EINVAL); | 422 423 np = devspec; 424 unit = -1; 425 /* 426 * If there is path/file info after the device info, then any missing 427 * slice or partition info should be considered a request to search for 428 * an appropriate partition. Otherwise we want to open the raw device 429 * itself and not try to fill in missing info by searching. --- 36 unchanged lines hidden (view full) --- 466 return (EPART); 467 cp++; 468 } 469 } else 470 return (EINVAL); 471 472 if (*cp != '\0' && *cp != ':') 473 return (EINVAL); |
474 dev = malloc(sizeof(*dev)); 475 if (dev == NULL) 476 return (ENOMEM); |
|
473 dev->dd.d_unit = unit; 474 dev->d_slice = slice; 475 dev->d_partition = partition; | 477 dev->dd.d_unit = unit; 478 dev->d_slice = slice; 479 dev->d_partition = partition; |
480 *idev = &dev->dd; |
|
476 if (path != NULL) 477 *path = (*cp == '\0') ? cp: cp + 1; 478 return (0); 479} | 481 if (path != NULL) 482 *path = (*cp == '\0') ? cp: cp + 1; 483 return (0); 484} |