mdmfs.c (3bb374ebb1eeb02762cce9d6bb5f40efb5eb5e62) | mdmfs.c (8a50130bbba0c21097203f701ac610019d785d33) |
---|---|
1/* 2 * Copyright (c) 2001 Dima Dorfman. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 232 unchanged lines hidden (view full) --- 241 unitstr += 5; 242 if (strncmp(unitstr, mdname, mdnamelen) == 0) 243 unitstr += mdnamelen; 244 if (*unitstr == '\0') { 245 autounit = true; 246 unit = -1; 247 } else { 248 unit = strtoul(unitstr, &p, 10); | 1/* 2 * Copyright (c) 2001 Dima Dorfman. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 232 unchanged lines hidden (view full) --- 241 unitstr += 5; 242 if (strncmp(unitstr, mdname, mdnamelen) == 0) 243 unitstr += mdnamelen; 244 if (*unitstr == '\0') { 245 autounit = true; 246 unit = -1; 247 } else { 248 unit = strtoul(unitstr, &p, 10); |
249 if ((unsigned)unit == ULONG_MAX || *p != '\0') | 249 if (unit == (unsigned)ULONG_MAX || *p != '\0') |
250 errx(1, "bad device unit: %s", unitstr); 251 } 252 253 mtpoint = argv[1]; 254 if (!have_mdtype) 255 mdtype = MD_SWAP; 256 if (softdep) 257 argappend(&newfs_arg, "-U"); --- 131 unchanged lines hidden (view full) --- 389 /* If the output format changes, we want to know about it. */ 390 assert(strncmp(linep, mdname, mdnamelen) == 0); 391 linebuf = malloc(linelen - mdnamelen + 1); 392 assert(linebuf != NULL); 393 /* Can't use strlcpy because linep is not NULL-terminated. */ 394 strncpy(linebuf, linep + mdnamelen, linelen); 395 linebuf[linelen] = '\0'; 396 unit = strtoul(linebuf, &p, 10); | 250 errx(1, "bad device unit: %s", unitstr); 251 } 252 253 mtpoint = argv[1]; 254 if (!have_mdtype) 255 mdtype = MD_SWAP; 256 if (softdep) 257 argappend(&newfs_arg, "-U"); --- 131 unchanged lines hidden (view full) --- 389 /* If the output format changes, we want to know about it. */ 390 assert(strncmp(linep, mdname, mdnamelen) == 0); 391 linebuf = malloc(linelen - mdnamelen + 1); 392 assert(linebuf != NULL); 393 /* Can't use strlcpy because linep is not NULL-terminated. */ 394 strncpy(linebuf, linep + mdnamelen, linelen); 395 linebuf[linelen] = '\0'; 396 unit = strtoul(linebuf, &p, 10); |
397 if ((unsigned)unit == ULONG_MAX || *p != '\n') | 397 if (unit == (unsigned)ULONG_MAX || *p != '\n') |
398 errx(1, "unexpected output from mdconfig (attach)"); 399 400 fclose(sfd); 401 close(fd); 402} 403 404/* 405 * Detach a memory disk. --- 102 unchanged lines hidden (view full) --- 508 assert(ug != NULL); 509 group = ug; 510 user = strsep(&group, ":"); 511 if (user == NULL || group == NULL || *user == '\0' || *group == '\0') 512 usage(); 513 514 /* Derive uid. */ 515 *uid = strtoul(user, &p, 10); | 398 errx(1, "unexpected output from mdconfig (attach)"); 399 400 fclose(sfd); 401 close(fd); 402} 403 404/* 405 * Detach a memory disk. --- 102 unchanged lines hidden (view full) --- 508 assert(ug != NULL); 509 group = ug; 510 user = strsep(&group, ":"); 511 if (user == NULL || group == NULL || *user == '\0' || *group == '\0') 512 usage(); 513 514 /* Derive uid. */ 515 *uid = strtoul(user, &p, 10); |
516 if ((unsigned)*uid == ULONG_MAX) | 516 if (*uid == (uid_t)ULONG_MAX) |
517 usage(); 518 if (*p != '\0') { 519 pw = getpwnam(user); 520 if (pw == NULL) 521 errx(1, "invalid user: %s", user); 522 *uid = pw->pw_uid; 523 mip->mi_have_uid = true; 524 } 525 526 /* Derive gid. */ 527 *gid = strtoul(group, &p, 10); | 517 usage(); 518 if (*p != '\0') { 519 pw = getpwnam(user); 520 if (pw == NULL) 521 errx(1, "invalid user: %s", user); 522 *uid = pw->pw_uid; 523 mip->mi_have_uid = true; 524 } 525 526 /* Derive gid. */ 527 *gid = strtoul(group, &p, 10); |
528 if ((unsigned)*gid == ULONG_MAX) | 528 if (*gid == (gid_t)ULONG_MAX) |
529 usage(); 530 if (*p != '\0') { 531 gr = getgrnam(group); 532 if (gr == NULL) 533 errx(1, "invalid group: %s", group); 534 *gid = gr->gr_gid; 535 mip->mi_have_gid = true; 536 } --- 138 unchanged lines hidden --- | 529 usage(); 530 if (*p != '\0') { 531 gr = getgrnam(group); 532 if (gr == NULL) 533 errx(1, "invalid group: %s", group); 534 *gid = gr->gr_gid; 535 mip->mi_have_gid = true; 536 } --- 138 unchanged lines hidden --- |