Date: Sun, 31 Oct 2010 23:51:57 GMT From: "Pedro F. Giffuni" <giffunip@tutopia.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/151850: style cleanups to msdos_newfs Message-ID: <201010312351.o9VNpvgo022625@www.freebsd.org> Resent-Message-ID: <201011010000.oA100Lpf084150@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 151850 >Category: bin >Synopsis: style cleanups to msdos_newfs >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Nov 01 00:00:21 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Pedro F. Giffuni >Release: 8.0-Release with relevant files updated from 9.0 >Organization: >Environment: FreeBSD mogwai.giffuni.net 8.0-RELEASE FreeBSD 8.0-RELEASE #13: Sat Jan 9 20:39:47 UTC 2010 pedro@mogwai.giffuni.net:/usr/src/sys/i386/compile/GENERIC i386 >Description: As a followup to bin/142526 there were some style changes that needed to be done as requested by bde@. - Undo C99 initializers. - Lots of tabs and space changes to conform to FreeBSD style. Result should be innocuous. >How-To-Repeat: >Fix: Patch follows. Patch attached with submission follows: --- newfs_msdos.c.orig 2010-04-03 12:36:58.000000000 +0000 +++ newfs_msdos.c 2010-04-03 17:18:12.000000000 +0000 @@ -55,6 +55,7 @@ #define NPB 2 /* nibbles per byte */ #define DOSMAGIC 0xaa55 /* DOS magic number */ +#define MAXBPS 4096 /* maximum bytes per sector */ #define MINBPS 512 /* minimum bytes per sector */ #define MAXSPC 128 /* maximum sectors per cluster */ #define MAXNFT 16 /* maximum number of FATs */ @@ -406,24 +407,29 @@ (int)delta, bpb.bpbSecPerTrack); bpb.bpbHugeSectors -= delta; } - if (bpb.bpbSecPerClust == 0) { /* set defaults */ - if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */ - bpb.bpbSecPerClust = 1; - else if (bpb.bpbHugeSectors <= (1<<17)) /* 64M -> 4k */ - bpb.bpbSecPerClust = 8; - else if (bpb.bpbHugeSectors <= (1<<19)) /* 256M -> 8k */ - bpb.bpbSecPerClust = 16; - else if (bpb.bpbHugeSectors <= (1<<21)) /* 1G -> 16k */ - bpb.bpbSecPerClust = 32; - else - bpb.bpbSecPerClust = 64; /* otherwise 32k */ - } + else + bpb.bpbSecPerClust /= (bpb.bpbBytesPerSec / MINBPS); + } + if (bpb.bpbSecPerClust == 0) { /* set defaults */ + if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */ + bpb.bpbSecPerClust = 1; + else if (bpb.bpbHugeSectors <= (1<<17)) /* 64M -> 4k */ + bpb.bpbSecPerClust = 8; + else if (bpb.bpbHugeSectors <= (1<<19)) /* 256M -> 8k */ + bpb.bpbSecPerClust = 16; + else if (bpb.bpbHugeSectors <= (1<<21)) /* 1G -> 16k */ + bpb.bpbSecPerClust = 32; + else + bpb.bpbSecPerClust = 64; /* otherwise 32k */ } if (!powerof2(bpb.bpbBytesPerSec)) errx(1, "bytes/sector (%u) is not a power of 2", bpb.bpbBytesPerSec); if (bpb.bpbBytesPerSec < MINBPS) errx(1, "bytes/sector (%u) is too small; minimum is %u", bpb.bpbBytesPerSec, MINBPS); + if (bpb.bpbBytesPerSec > MAXBPS) + printf( "WARNING: bytes/sector (%u) is bigger than %u", + bpb.bpbBytesPerSec, MAXBPS); if (!(fat = opt_F)) { if (opt_f) fat = 12; @@ -447,6 +453,9 @@ opt_b, bpb.bpbBytesPerSec * MAXSPC); bpb.bpbSecPerClust = opt_b / bpb.bpbBytesPerSec; } + if (bpb.bpbSecPerClust * bpb.bpbBytesPerSec > 32 * 1024) + printf("WARNING: bytes per sector (%u) is greater than 32K", + bpb.bpbSecPerClust * bpb.bpbBytesPerSec); if (opt_c) { if (!powerof2(opt_c)) errx(1, "sectors/cluster (%u) is not a power of 2", opt_c); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010312351.o9VNpvgo022625>