newfs_msdos.c (190927) | newfs_msdos.c (190929) |
---|---|
1/* 2 * Copyright (c) 1998 Robert Nordier 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 --- 13 unchanged lines hidden (view full) --- 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 23 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 25 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#ifndef lint 29static const char rcsid[] = | 1/* 2 * Copyright (c) 1998 Robert Nordier 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 --- 13 unchanged lines hidden (view full) --- 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 23 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 25 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#ifndef lint 29static const char rcsid[] = |
30 "$FreeBSD: head/sbin/newfs_msdos/newfs_msdos.c 190927 2009-04-11 14:24:54Z ed $"; | 30 "$FreeBSD: head/sbin/newfs_msdos/newfs_msdos.c 190929 2009-04-11 14:33:10Z ed $"; |
31#endif /* not lint */ 32 33#include <sys/param.h> 34#include <sys/fdcio.h> 35#include <sys/disk.h> 36#include <sys/disklabel.h> 37#include <sys/mount.h> 38#include <sys/stat.h> --- 312 unchanged lines hidden (view full) --- 351 fname = *argv++; 352 if (!strchr(fname, '/')) { 353 snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname); 354 if (!(fname = strdup(buf))) 355 err(1, NULL); 356 } 357 dtype = *argv; 358 if (opt_create) { | 31#endif /* not lint */ 32 33#include <sys/param.h> 34#include <sys/fdcio.h> 35#include <sys/disk.h> 36#include <sys/disklabel.h> 37#include <sys/mount.h> 38#include <sys/stat.h> --- 312 unchanged lines hidden (view full) --- 351 fname = *argv++; 352 if (!strchr(fname, '/')) { 353 snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname); 354 if (!(fname = strdup(buf))) 355 err(1, NULL); 356 } 357 dtype = *argv; 358 if (opt_create) { |
359 off_t pos; 360 | |
361 if (opt_N) 362 errx(1, "create (-C) is incompatible with -N"); 363 fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644); 364 if (fd == -1) 365 errx(1, "failed to create %s", fname); | 359 if (opt_N) 360 errx(1, "create (-C) is incompatible with -N"); 361 fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644); 362 if (fd == -1) 363 errx(1, "failed to create %s", fname); |
366 pos = lseek(fd, opt_create - 1, SEEK_SET); 367 if (write(fd, "\0", 1) != 1) | 364 if (ftruncate(fd, opt_create)) |
368 errx(1, "failed to initialize %jd bytes", (intmax_t)opt_create); | 365 errx(1, "failed to initialize %jd bytes", (intmax_t)opt_create); |
369 pos = lseek(fd, 0, SEEK_SET); | |
370 } else if ((fd = open(fname, opt_N ? O_RDONLY : O_RDWR)) == -1 || 371 fstat(fd, &sb)) 372 err(1, "%s", fname); 373 if (!opt_N) 374 check_mounted(fname, sb.st_mode); 375 if (!S_ISCHR(sb.st_mode)) 376 warnx("warning, %s is not a character device", fname); 377 if (opt_ofs && opt_ofs != lseek(fd, opt_ofs, SEEK_SET)) --- 636 unchanged lines hidden --- | 366 } else if ((fd = open(fname, opt_N ? O_RDONLY : O_RDWR)) == -1 || 367 fstat(fd, &sb)) 368 err(1, "%s", fname); 369 if (!opt_N) 370 check_mounted(fname, sb.st_mode); 371 if (!S_ISCHR(sb.st_mode)) 372 warnx("warning, %s is not a character device", fname); 373 if (opt_ofs && opt_ofs != lseek(fd, opt_ofs, SEEK_SET)) --- 636 unchanged lines hidden --- |