mirror of
https://github.com/openharmony/third_party_newfs_msdos.git
synced 2026-06-30 21:27:59 -04:00
!26 Deleted all code,and moving the path to FreeBSD/sbin.
Merge pull request !26 from xlfeng/master
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
config("vfat-defaults") {
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wno-unused-function",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-unused-variable",
|
||||
"-D_FILE_OFFSET_BITS=64",
|
||||
"-D_GNU_SOURCE",
|
||||
"-DSIGINFO=SIGUSR2",
|
||||
"-Dnitems(x)=(sizeof((x))/sizeof((x)[0]))",
|
||||
"-Wno-implicit-function-declaration",
|
||||
"-DMAKEFS",
|
||||
"-D_MACHINE_IOCTL_FD_H_",
|
||||
]
|
||||
include_dirs = [ "//third_party/FreeBSD/sys" ]
|
||||
}
|
||||
|
||||
###################################################
|
||||
##Build newfs_msdos
|
||||
ohos_executable("newfs_msdos") {
|
||||
configs = [ ":vfat-defaults" ]
|
||||
sources = [
|
||||
"mkfs_msdos.c",
|
||||
"newfs_msdos.c",
|
||||
]
|
||||
|
||||
include_dirs = []
|
||||
install_enable = true
|
||||
deps = []
|
||||
subsystem_name = "filemanagement"
|
||||
part_name = "storage_service"
|
||||
install_images = [ "system" ]
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
|
||||
|
||||
The compilation of software known as FreeBSD is distributed under the
|
||||
following terms:
|
||||
|
||||
Copyright (c) 1992-2020 The FreeBSD Project.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
The 4.4BSD and 4.4BSD-Lite software is distributed under the following
|
||||
terms:
|
||||
|
||||
All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite
|
||||
Releases is copyrighted by The Regents of the University of California.
|
||||
|
||||
Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
|
||||
The Regents of the University of California. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
This product includes software developed by the University of
|
||||
California, Berkeley and its contributors.
|
||||
4. Neither the name of the University nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
The Institute of Electrical and Electronics Engineers and the American
|
||||
National Standards Committee X3, on Information Processing Systems have
|
||||
given us permission to reprint portions of their documentation.
|
||||
|
||||
In the following statement, the phrase ``this text'' refers to portions
|
||||
of the system documentation.
|
||||
|
||||
Portions of this text are reprinted and reproduced in electronic form in
|
||||
the second BSD Networking Software Release, from IEEE Std 1003.1-1988, IEEE
|
||||
Standard Portable Operating System Interface for Computer Environments
|
||||
(POSIX), copyright C 1988 by the Institute of Electrical and Electronics
|
||||
Engineers, Inc. In the event of any discrepancy between these versions
|
||||
and the original IEEE Standard, the original IEEE Standard is the referee
|
||||
document.
|
||||
|
||||
In the following statement, the phrase ``This material'' refers to portions
|
||||
of the system documentation.
|
||||
|
||||
This material is reproduced with permission from American National
|
||||
Standards Committee X3, on Information Processing Systems. Computer and
|
||||
Business Equipment Manufacturers Association (CBEMA), 311 First St., NW,
|
||||
Suite 500, Washington, DC 20001-2178. The developmental work of
|
||||
Programming Language C was completed by the X3J11 Technical Committee.
|
||||
|
||||
The views and conclusions contained in the software and documentation are
|
||||
those of the authors and should not be interpreted as representing official
|
||||
policies, either expressed or implied, of the Regents of the University
|
||||
of California.
|
||||
|
||||
|
||||
NOTE: The copyright of UC Berkeley's Berkeley Software Distribution ("BSD")
|
||||
source has been updated. The copyright addendum may be found at
|
||||
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change and is
|
||||
included below.
|
||||
|
||||
July 22, 1999
|
||||
|
||||
To All Licensees, Distributors of Any Version of BSD:
|
||||
|
||||
As you know, certain of the Berkeley Software Distribution ("BSD") source
|
||||
code files require that further distributions of products containing all or
|
||||
portions of the software, acknowledge within their advertising materials
|
||||
that such products contain software developed by UC Berkeley and its
|
||||
contributors.
|
||||
|
||||
Specifically, the provision reads:
|
||||
|
||||
" * 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors."
|
||||
|
||||
Effective immediately, licensees and distributors are no longer required to
|
||||
include the acknowledgement within advertising materials. Accordingly, the
|
||||
foregoing paragraph of those BSD Unix files containing it is hereby deleted
|
||||
in its entirety.
|
||||
|
||||
William Hoskins
|
||||
Director, Office of Technology Licensing
|
||||
University of California, Berkeley
|
||||
@@ -1,14 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PACKAGE=runtime
|
||||
PROG= newfs_msdos
|
||||
MAN= newfs_msdos.8
|
||||
SRCS= newfs_msdos.c mkfs_msdos.c
|
||||
|
||||
# XXX - this is verboten
|
||||
.if ${MACHINE_CPUARCH} == "arm"
|
||||
WARNS?= 3
|
||||
.endif
|
||||
CSTD= c11
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,17 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
||||
@@ -1,84 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
All configurations in this file will be merged to OAT-Default.xml, if you have any questions or concerns, please create issue in OpenHarmony/tools_oat and @jalenchen or chenyaxun.
|
||||
|
||||
licensefile:
|
||||
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
|
||||
|
||||
policylist:
|
||||
1. policy: If the OAT-Default.xml policies do not meet your requirements, please add policies here.
|
||||
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
|
||||
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
|
||||
3. policyitem type:
|
||||
"compatibility" is used to check license compatibility in the specified path;
|
||||
"license" is used to check source license header in the specified path;
|
||||
"copyright" is used to check source copyright header in the specified path;
|
||||
"import" is used to check source dependency in the specified path, such as import ... ,include ...
|
||||
"filetype" is used to check file type in the specified path, supported file types: archive, binary
|
||||
"filename" is used to check whether the specified file exists in the specified path(projectroot means the root dir of the project), supported file names: LICENSE, README, README.OpenSource
|
||||
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
|
||||
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
|
||||
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
|
||||
7. policyitem filefilter: Used to bind filefilter which define filter rules.
|
||||
7. policyitem desc: Used to describe the reason of this policy item, committers will check this while merging the code.
|
||||
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
|
||||
|
||||
Note:If the text contains special characters, please escape them according to the following rules:
|
||||
" == "
|
||||
& == &
|
||||
' == '
|
||||
< == <
|
||||
> == >
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile>COPYRIGHT</licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<policyitem type="compatibility" name="GPLStyleLicense" path="*.*" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter" desc="独立进程,独立使用"/>
|
||||
<policyitem type="compatibility" name="BSD-2-Clause" path="*.*" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter" desc="独立进程,独立使用"/>
|
||||
<policyitem type="compatibility" name="BSD-4-Clause" path="*.*" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter" desc="独立进程,独立使用"/>
|
||||
<policyitem type="compatibility" name="SPDX:BSD-2-Clause-FreeBSD" path="*.*" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter" desc="独立进程,独立使用"/>
|
||||
<policyitem type="license" name="SPDX:BSD-2-Clause-FreeBSD" path=".*" rule="may" group="defaultGroup" filefilter="" desc=""/>
|
||||
<policyitem type="license" name="BSD-2-Clause" path=".*" rule="may" group="defaultGroup" filefilter="" desc=""/>
|
||||
<policyitem type="license" name="BSD-4-Clause" path=".*" rule="may" group="defaultGroup" filefilter="" desc=""/>
|
||||
<policyitem type="copyright" name="Robert Nordier" path=".*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc=""/>
|
||||
<policyitem type="copyright" name="The NetBSD Foundation, Inc." path=".*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc=""/>
|
||||
<policyitem type="copyright" name="Huawei Device Co., Ltd." path=".*" rule="may" group="defaultGroup" filefilter="copyrightPolicyFilter" desc=""/>
|
||||
</policy>
|
||||
</policylist>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<filteritem type="filename" name="README.OpenSource" desc=""/>
|
||||
<filteritem type="filename" name="Makefile.depend" desc="NoLicenseHeader"/>
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
</filefilter>
|
||||
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
|
||||
</filefilter>
|
||||
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
|
||||
</filefilter>
|
||||
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
|
||||
</filefilter>
|
||||
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
</filefilter>
|
||||
</filefilterlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
||||
@@ -1,11 +0,0 @@
|
||||
[
|
||||
{
|
||||
"Name" : "newfs_msdos",
|
||||
"License" : "BSD-4-Clause",
|
||||
"License File" : "COPYRIGHT",
|
||||
"Version Number" : "freebsd-src 12.2.0",
|
||||
"Owner" : "Berkeley",
|
||||
"Upstream URL" : "https://github.com/freebsd/freebsd-src/tree/master/sbin/newfs_msdos",
|
||||
"Description" : "The newfs_msdos utility creates a FAT12, FAT16, or FAT32 file system on device or file named special, using disktab(5) entry disktype to determine geometry, if required."
|
||||
}
|
||||
]
|
||||
@@ -1,51 +0,0 @@
|
||||
# third_party_newfs_msdos
|
||||
|
||||
#### 介绍
|
||||
newfs_msdos是Fat32格式化工具。实现在设备上构建一个FAT12、FAT16或FAT32的文件OS(FAT)文件系统。
|
||||
|
||||
命令格式:
|
||||
|
||||
newfs_msdos [-N] [-@ offset] [-A] [-B boot] [-C create-size]
|
||||
[-F FAT-type] [-I VolumeID] [-L label] [-O OEM]
|
||||
[-S sector-size] [-T timestamp] [-a FAT-size] [-b block-size]
|
||||
[-c cluster-size] [-e DirEnts] [-f format] [-h heads]
|
||||
[-i info] [-k backup] [-m media] [-n FATs] [-o hidden]
|
||||
[-r reserved] [-s total] [-u track-size] special [disktype]
|
||||
如果 special 不包含 / 并且未使用 -C,则假定它是设备名称,并且 /dev/ 被添加到名称以构造实际设备名称。 要处理当前目录中的文件,请使用 ./filename。
|
||||
|
||||
参数选项如下:
|
||||
- N :不要创建文件系统:只需打印参数。
|
||||
- -@ offset :在设备或文件中以字节为单位的指定偏移量处构建文件系统。 附加到偏移量的后缀 s、k、m、g(小写或大写)分别指定该数字以扇区、千字节、兆字节或千兆字节为单位。
|
||||
- -A :尝试群集对齐根目录,对 SD 卡有用。
|
||||
- -B boot :从文件中获取引导程序。
|
||||
- -C create-size :创建具有指定大小的图像文件。 附加到大小的后缀字符被解释为 -@ 选项。该文件是通过截断具有相同名称的任何现有文件并将其调整为请求的大小来创建的。 如果文件系统支持稀疏文件,则占用的磁盘空间可能小于参数指定的大小。
|
||||
- -F FAT-type :FAT类型(12/16/32)
|
||||
- -I VolumeID :卷 ID,十进制或十六进制 (0x...) 格式的 32 位数字。
|
||||
- -L label :卷标(最多 11 个字符)。 标签应仅包含在常规 DOS (8+3) 文件名中允许的那些字符。
|
||||
- -O OEM :OEM 字符串(最多 8 个字符)。 默认为“BSD 4.4”。、
|
||||
- -S sector-size :每个扇区的字节数。 可接受的值为 512 到 32768 范围内的 2 的幂。
|
||||
- -T timestamp :创建文件系统,就好像当前时间是时间戳一样。 默认文件系统卷 ID 来自时间。timestamp 可以是路径名(其中时间戳来自该文件)或解释为自纪元以来的秒数的整数值。
|
||||
- -a FAT-size :每个 FAT 的扇区数。
|
||||
- -b block-size :文件系统块大小(每个簇的字节数)
|
||||
- -c cluster-size :每个集群的扇区。 可接受的值为 1 到 128 范围内的 2 的幂。
|
||||
- -e dirents :根目录的条目数(仅限 FAT12 和 FAT16)
|
||||
- -f format :指定标准(软盘)格式。 八种标准格式是(以千字节为单位的容量):160、180、320、360、720、1200、1440、2880。
|
||||
- -h heads :驱动头数
|
||||
- -i info :文件系统信息扇区的位置(仅限 FAT32)。 0xffff 值表示没有信息扇区。
|
||||
- -k backup :备份引导扇区的位置(仅限 FAT32)。 0xffff 值表示没有备份扇区。
|
||||
- -m media :媒体描述符(可接受的范围 0xf0 到 0xff)。
|
||||
- -n FATs :FAT 的数量。 可接受的值为 1 到 16(含)。 默认值为 2。
|
||||
- -o hidden :隐藏扇区数
|
||||
- -r reserved :保留扇区数。
|
||||
- -s total :文件系统大小。
|
||||
- -u track-size :每个磁道的扇区数。
|
||||
|
||||
#### 来源
|
||||
1. newfs_msdos是[freebsd/freebsd-src](https://github.com/freebsd/freebsd-src/tree/master/sbin/newfs_msdos)下的一个功能。
|
||||
2. BSD提供的[使用手册](https://www.freebsd.org/cgi/man.cgi?query=newfs_msdos)。
|
||||
3. 可以到[freebsd-src](https://github.com/freebsd/freebsd-src.git)了解源代码。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-196
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MKFS_DEFINE_H
|
||||
#define MKFS_DEFINE_H
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* BSD_NPARTS_MIN,BSD_NDRIVEDATA,BSD_NSPARE
|
||||
* Link: https://github.com/freebsd/freebsd-src/
|
||||
* Path: freebsd-src/sys/sys/disk/bsd.h
|
||||
*/
|
||||
#define BSD_NPARTS_MIN 8
|
||||
|
||||
/* Drive-type specific data size (in number of 32-bit inegrals) */
|
||||
#define BSD_NDRIVEDATA 5
|
||||
|
||||
/* Number of spare 32-bit integrals following drive-type data */
|
||||
#define BSD_NSPARE 5
|
||||
|
||||
/*
|
||||
* MAXPHYS
|
||||
* Link: https://github.com/freebsd/freebsd-src/
|
||||
* Path: freebsd-src/sys/sys/param.h
|
||||
*/
|
||||
#ifdef __ILP32__
|
||||
#define MAXPHYS (128 * 1024)
|
||||
#else
|
||||
#define MAXPHYS (1024 * 1024)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* DIOCGMEDIASIZE,DIOCGFWSECTORS,DIOCGSECTORSIZE,DIOCGFWHEADS
|
||||
* Link: https://github.com/freebsd/freebsd-src/
|
||||
* Path: freebsd-src/sys/sys/disk.h
|
||||
*/
|
||||
#define DIOCGMEDIASIZE _IOR('d', 129, off_t) /* Get media size in bytes */
|
||||
/*
|
||||
* Get the size of the entire device in bytes. This should be a
|
||||
* multiple of the sector size.
|
||||
*/
|
||||
|
||||
#define DIOCGFWSECTORS _IOR('d', 130, u_int) /* Get firmware's sectorcount */
|
||||
/*
|
||||
* Get the firmware's notion of number of sectors per track. This
|
||||
* value is mostly used for compatibility with various ill designed
|
||||
* disk label formats. Don't use it unless you have to.
|
||||
*/
|
||||
|
||||
#define DIOCGSECTORSIZE _IOR('d', 128, u_int)
|
||||
/*
|
||||
* Get the sector size of the device in bytes. The sector size is the
|
||||
* smallest unit of data which can be transferred from this device.
|
||||
* Usually this is a power of 2 but it might not be (i.e. CDROM audio).
|
||||
*/
|
||||
|
||||
#define DIOCGFWHEADS _IOR('d', 131, u_int) /* Get firmware's headcount */
|
||||
/*
|
||||
* Get the firmwares notion of number of heads per cylinder. This
|
||||
* value is mostly used for compatibility with various ill designed
|
||||
* disk label formats. Don't use it unless you have to.
|
||||
*/
|
||||
|
||||
/*
|
||||
* FD_GTYPE
|
||||
* Link: https://github.com/freebsd/freebsd-src/
|
||||
* Path: freebsd-src/sys/sys/fdcio.h
|
||||
*/
|
||||
#ifndef _MACHINE_IOCTL_FD_H_
|
||||
#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* disklabel
|
||||
* Link: https://github.com/freebsd/freebsd-src/
|
||||
* Path: freebsd-src/sys/sys/disk/bsd.h
|
||||
*/
|
||||
struct disklabel {
|
||||
uint32_t d_magic; /* the magic number */
|
||||
uint16_t d_type; /* drive type */
|
||||
uint16_t d_subtype; /* controller/d_type specific */
|
||||
char d_typename[16]; /* type name, e.g. "eagle" */
|
||||
|
||||
char d_packname[16]; /* pack identifier */
|
||||
|
||||
/* disk geometry: */
|
||||
uint32_t d_secsize; /* # of bytes per sector */
|
||||
uint32_t d_nsectors; /* # of data sectors per track */
|
||||
uint32_t d_ntracks; /* # of tracks per cylinder */
|
||||
uint32_t d_ncylinders; /* # of data cylinders per unit */
|
||||
uint32_t d_secpercyl; /* # of data sectors per cylinder */
|
||||
uint32_t d_secperunit; /* # of data sectors per unit */
|
||||
|
||||
/*
|
||||
* Spares (bad sector replacements) below are not counted in
|
||||
* d_nsectors or d_secpercyl. Spare sectors are assumed to
|
||||
* be physical sectors which occupy space at the end of each
|
||||
* track and/or cylinder.
|
||||
*/
|
||||
uint16_t d_sparespertrack; /* # of spare sectors per track */
|
||||
uint16_t d_sparespercyl; /* # of spare sectors per cylinder */
|
||||
/*
|
||||
* Alternate cylinders include maintenance, replacement, configuration
|
||||
* description areas, etc.
|
||||
*/
|
||||
uint32_t d_acylinders; /* # of alt. cylinders per unit */
|
||||
|
||||
/* hardware characteristics: */
|
||||
/*
|
||||
* d_interleave, d_trackskew and d_cylskew describe perturbations
|
||||
* in the media format used to compensate for a slow controller.
|
||||
* Interleave is physical sector interleave, set up by the
|
||||
* formatter or controller when formatting. When interleaving is
|
||||
* in use, logically adjacent sectors are not physically
|
||||
* contiguous, but instead are separated by some number of
|
||||
* sectors. It is specified as the ratio of physical sectors
|
||||
* traversed per logical sector. Thus an interleave of 1:1
|
||||
* implies contiguous layout, while 2:1 implies that logical
|
||||
* sector 0 is separated by one sector from logical sector 1.
|
||||
* d_trackskew is the offset of sector 0 on track N relative to
|
||||
* sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
|
||||
* is the offset of sector 0 on cylinder N relative to sector 0
|
||||
* on cylinder N-1.
|
||||
*/
|
||||
uint16_t d_rpm; /* rotational speed */
|
||||
uint16_t d_interleave; /* hardware sector interleave */
|
||||
uint16_t d_trackskew; /* sector 0 skew, per track */
|
||||
uint16_t d_cylskew; /* sector 0 skew, per cylinder */
|
||||
uint32_t d_headswitch; /* head switch time, usec */
|
||||
uint32_t d_trkseek; /* track-to-track seek, usec */
|
||||
uint32_t d_flags; /* generic flags */
|
||||
uint32_t d_drivedata[BSD_NDRIVEDATA]; /* drive-type specific data */
|
||||
uint32_t d_spare[BSD_NSPARE]; /* reserved for future use */
|
||||
uint32_t d_magic2; /* the magic number (again) */
|
||||
uint16_t d_checksum; /* xor of data incl. partitions */
|
||||
|
||||
/* filesystem and partition information: */
|
||||
uint16_t d_npartitions; /* number of partitions in following */
|
||||
uint32_t d_bbsize; /* size of boot area at sn0, bytes */
|
||||
uint32_t d_sbsize; /* max size of fs superblock, bytes */
|
||||
struct partition { /* the partition table */
|
||||
uint32_t p_size; /* number of sectors in partition */
|
||||
uint32_t p_offset; /* starting sector */
|
||||
uint32_t p_fsize; /* filesystem basic fragment size */
|
||||
uint8_t p_fstype; /* filesystem type, see below */
|
||||
uint8_t p_frag; /* filesystem fragments per block */
|
||||
uint16_t p_cpg; /* filesystem cylinders per group */
|
||||
} d_partitions[BSD_NPARTS_MIN]; /* actually may be more */
|
||||
};
|
||||
|
||||
/*
|
||||
* fd_type
|
||||
* Link: https://github.com/freebsd/freebsd-src/
|
||||
* Path: freebsd-src/sys/sys/fdcio.h
|
||||
*/
|
||||
struct fd_type {
|
||||
int sectrac; /* sectors per track */
|
||||
int secsize; /* size code for sectors */
|
||||
int datalen; /* data len when secsize = 0 */
|
||||
int gap; /* gap len between sectors */
|
||||
int tracks; /* total number of cylinders */
|
||||
int size; /* size of disk in sectors */
|
||||
int trans; /* transfer speed code */
|
||||
int heads; /* number of heads */
|
||||
int f_gap; /* format gap len */
|
||||
int f_inter; /* format interleave factor */
|
||||
int offset_side2; /* offset of sectors on side2 */
|
||||
int flags; /* misc. features */
|
||||
#define FL_MFM 0x0001 /* MFM recording */
|
||||
#define FL_2STEP 0x0002 /* 2 steps between cylinders */
|
||||
#define FL_PERPND 0x0004 /* perpendicular recording */
|
||||
#define FL_AUTO 0x0008 /* autodetect format */
|
||||
};
|
||||
#endif //MKFS_DEFINE_H
|
||||
-1100
File diff suppressed because it is too large
Load Diff
@@ -1,75 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
/* $NetBSD: mkfs_msdos.h,v 1.3 2015/10/16 17:38:17 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "mkfs_define.h"
|
||||
|
||||
#define ALLOPTS \
|
||||
AOPT('@', off_t, offset, 0, "Offset in device") \
|
||||
AOPT('A', bool, align, -2, "Attempt to cluster align root directory") \
|
||||
AOPT('B', const char *, bootstrap, -1, "Bootstrap file") \
|
||||
AOPT('C', off_t, create_size, 0, "Create file") \
|
||||
AOPT('F', uint8_t, fat_type, 12, "FAT type (12, 16, or 32)") \
|
||||
AOPT('I', uint32_t, volume_id, 0, "Volume ID") \
|
||||
AOPT('L', const char *, volume_label, -1, "Volume Label") \
|
||||
AOPT('N', bool, no_create, -2, "Don't create filesystem, print params only") \
|
||||
AOPT('O', const char *, OEM_string, -1, "OEM string") \
|
||||
AOPT('S', uint16_t, bytes_per_sector, 1, "Bytes per sector") \
|
||||
AOPT('T', time_t, timestamp, 0, "Timestamp") \
|
||||
AOPT('a', uint32_t, sectors_per_fat, 1, "Sectors per FAT") \
|
||||
AOPT('b', uint32_t, block_size, 1, "Block size") \
|
||||
AOPT('c', uint8_t, sectors_per_cluster, 1, "Sectors per cluster") \
|
||||
AOPT('e', uint16_t, directory_entries, 1, "Directory entries") \
|
||||
AOPT('f', const char *, floppy, -1, "Standard format floppies (160,180,320,360,640,720,1200,1232,1440,2880)") \
|
||||
AOPT('h', uint16_t, drive_heads, 1, "Drive heads") \
|
||||
AOPT('i', uint16_t, info_sector, 1, "Info sector") \
|
||||
AOPT('k', uint16_t, backup_sector, 1, "Backup sector") \
|
||||
AOPT('m', uint8_t, media_descriptor, 0, "Media descriptor") \
|
||||
AOPT('n', uint8_t, num_FAT, 1, "Number of FATs") \
|
||||
AOPT('o', uint32_t, hidden_sectors, 0, "Hidden sectors") \
|
||||
AOPT('r', uint16_t, reserved_sectors, 1, "Reserved sectors") \
|
||||
AOPT('s', uint32_t, size, 1, "File System size") \
|
||||
AOPT('u', uint16_t, sectors_per_track, 1, "Sectors per track")
|
||||
|
||||
struct msdos_options {
|
||||
#define AOPT(_opt, _type, _name, _min, _desc) _type _name;
|
||||
ALLOPTS
|
||||
#undef AOPT
|
||||
uint32_t timestamp_set:1;
|
||||
uint32_t volume_id_set:1;
|
||||
uint32_t media_descriptor_set:1;
|
||||
uint32_t hidden_sectors_set:1;
|
||||
};
|
||||
|
||||
int mkfs_msdos(const char *, const char *, const struct msdos_options *);
|
||||
-251
@@ -1,251 +0,0 @@
|
||||
.\" Copyright (c) 1998 Robert Nordier
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in
|
||||
.\" the documentation and/or other materials provided with the
|
||||
.\" distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
|
||||
.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
|
||||
.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 14, 2018
|
||||
.Dt NEWFS_MSDOS 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm newfs_msdos
|
||||
.Nd construct a new MS-DOS (FAT) file system
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl N
|
||||
.Op Fl @ Ar offset
|
||||
.Op Fl A
|
||||
.Op Fl B Ar boot
|
||||
.Op Fl C Ar create-size
|
||||
.Op Fl F Ar FAT-type
|
||||
.Op Fl I Ar VolumeID
|
||||
.Op Fl L Ar label
|
||||
.Op Fl O Ar OEM
|
||||
.Op Fl S Ar sector-size
|
||||
.Op Fl T Ar timestamp
|
||||
.Op Fl a Ar FAT-size
|
||||
.Op Fl b Ar block-size
|
||||
.Op Fl c Ar cluster-size
|
||||
.Op Fl e Ar DirEnts
|
||||
.Op Fl f Ar format
|
||||
.Op Fl h Ar heads
|
||||
.Op Fl i Ar info
|
||||
.Op Fl k Ar backup
|
||||
.Op Fl m Ar media
|
||||
.Op Fl n Ar FATs
|
||||
.Op Fl o Ar hidden
|
||||
.Op Fl r Ar reserved
|
||||
.Op Fl s Ar total
|
||||
.Op Fl u Ar track-size
|
||||
.Ar special
|
||||
.Op Ar disktype
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility creates a FAT12, FAT16, or FAT32 file system on device or file named
|
||||
.Ar special ,
|
||||
using
|
||||
.Xr disktab 5
|
||||
entry
|
||||
.Ar disktype
|
||||
to determine geometry, if required.
|
||||
.Pp
|
||||
If
|
||||
.Ar special
|
||||
does not contain a
|
||||
.Ar /
|
||||
and
|
||||
.Fl C
|
||||
is not used, it is assumed to be a device name and
|
||||
.Ar /dev/
|
||||
is prepended to the name to construct the actual device name.
|
||||
To work a file in the current directory use
|
||||
.Ar ./filename
|
||||
.Pp
|
||||
The options are as follow:
|
||||
.Bl -tag -width indent
|
||||
.It Fl N
|
||||
Do not create a file system: just print out parameters.
|
||||
.It Fl @ Ar offset
|
||||
Build the filesystem at the specified offset in bytes in the device or file.
|
||||
A suffix s, k, m, g (lower or upper case)
|
||||
appended to the offset specifies that the
|
||||
number is in sectors, kilobytes, megabytes or gigabytes, respectively.
|
||||
.It Fl A
|
||||
Attempt to cluster align root directory, useful for SD card.
|
||||
.It Fl B Ar boot
|
||||
Get bootstrap from file.
|
||||
.It Fl C Ar create-size
|
||||
Create the image file with the specified size.
|
||||
A suffix character appended to the size is interpreted as for the
|
||||
.Fl @
|
||||
option.
|
||||
The file is created by truncating any existing file with the same name and
|
||||
resizing it to the requested size.
|
||||
If the file system supports sparse files, the space occupied on disk may be
|
||||
smaller than the size specified as parameter.
|
||||
.It Fl F Ar FAT-type
|
||||
FAT type (one of 12, 16, or 32).
|
||||
.It Fl I Ar VolumeID
|
||||
Volume ID, a 32 bit number in decimal or hexadecimal (0x...) format.
|
||||
.It Fl L Ar label
|
||||
Volume label (up to 11 characters).
|
||||
The label should consist of
|
||||
only those characters permitted in regular DOS (8+3) filenames.
|
||||
.It Fl O Ar OEM
|
||||
OEM string (up to 8 characters).
|
||||
The default is
|
||||
.Qq Li "BSD4.4 " .
|
||||
.It Fl S Ar sector-size
|
||||
Number of bytes per sector.
|
||||
Acceptable values are powers of 2
|
||||
in the range 512 through 32768, inclusive.
|
||||
.It Fl T Ar timestamp
|
||||
Create the filesystem as though the current time is
|
||||
.Ar timestamp .
|
||||
The default filesystem volume ID is derived from the time.
|
||||
.Ar timestamp
|
||||
can be a pathname (where the timestamp is derived from
|
||||
that file) or an integer value interpreted
|
||||
as the number of seconds since the Epoch.
|
||||
.It Fl a Ar FAT-size
|
||||
Number of sectors per FAT.
|
||||
.It Fl b Ar block-size
|
||||
File system block size (bytes per cluster).
|
||||
This should resolve to an
|
||||
acceptable number of sectors per cluster (see below).
|
||||
.It Fl c Ar cluster-size
|
||||
Sectors per cluster.
|
||||
Acceptable values are powers of 2 in the range
|
||||
1 through 128.
|
||||
If the block or cluster size are not specified, the code
|
||||
uses a cluster between 512 bytes and 32K depending on
|
||||
the filesystem size.
|
||||
.It Fl e Ar DirEnts
|
||||
Number of root directory entries (FAT12 and FAT16 only).
|
||||
.It Fl f Ar format
|
||||
Specify a standard (floppy disk) format.
|
||||
The standard formats
|
||||
are (capacities in kilobytes): 160, 180, 320, 360, 640, 720, 1200,
|
||||
1232, 1440, 2880.
|
||||
.It Fl h Ar heads
|
||||
Number of drive heads.
|
||||
.It Fl i Ar info
|
||||
Location of the file system info sector (FAT32 only).
|
||||
A value of 0xffff signifies no info sector.
|
||||
.It Fl k Ar backup
|
||||
Location of the backup boot sector (FAT32 only).
|
||||
A value
|
||||
of 0xffff signifies no backup sector.
|
||||
.It Fl m Ar media
|
||||
Media descriptor (acceptable range 0xf0 to 0xff).
|
||||
.It Fl n Ar FATs
|
||||
Number of FATs.
|
||||
Acceptable values are 1 to 16 inclusive.
|
||||
The default
|
||||
is 2.
|
||||
.It Fl o Ar hidden
|
||||
Number of hidden sectors.
|
||||
.It Fl r Ar reserved
|
||||
Number of reserved sectors.
|
||||
.It Fl s Ar total
|
||||
File system size.
|
||||
.It Fl u Ar track-size
|
||||
Number of sectors per track.
|
||||
.El
|
||||
.Sh NOTES
|
||||
If some parameters (e.g., size, number of sectors, etc.) are not specified
|
||||
through options or disktype, the program tries to generate them automatically.
|
||||
In particular, the size is determined as the device or file size minus the
|
||||
offset specified with the
|
||||
.Fl @
|
||||
option.
|
||||
When the geometry is not available, it is assumed to be 63 sectors, 255 heads.
|
||||
The size is then rounded to become a multiple of the track size and avoid
|
||||
complaints by some filesystem code.
|
||||
.Pp
|
||||
FAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter
|
||||
Block)" in the first of the "reserved" sectors which precede the actual
|
||||
file system.
|
||||
For reference purposes, this structure is presented
|
||||
below.
|
||||
.Bd -literal
|
||||
struct bsbpb {
|
||||
uint16_t bpbBytesPerSec; /* [-S] bytes per sector */
|
||||
uint8_t bpbSecPerClust; /* [-c] sectors per cluster */
|
||||
uint16_t bpbResSectors; /* [-r] reserved sectors */
|
||||
uint8_t bpbFATs; /* [-n] number of FATs */
|
||||
uint16_t bpbRootDirEnts; /* [-e] root directory entries */
|
||||
uint16_t bpbSectors; /* [-s] total sectors */
|
||||
uint8_t bpbMedia; /* [-m] media descriptor */
|
||||
uint16_t bpbFATsecs; /* [-a] sectors per FAT */
|
||||
uint16_t bpbSecPerTrack; /* [-u] sectors per track */
|
||||
uint16_t bpbHeads; /* [-h] drive heads */
|
||||
uint32_t bpbHiddenSecs; /* [-o] hidden sectors */
|
||||
uint32_t bpbHugeSectors; /* [-s] big total sectors */
|
||||
};
|
||||
/* FAT32 extensions */
|
||||
struct bsxbpb {
|
||||
uint32_t bpbBigFATsecs; /* [-a] big sectors per FAT */
|
||||
uint16_t bpbExtFlags; /* control flags */
|
||||
uint16_t bpbFSVers; /* file system version */
|
||||
uint32_t bpbRootClust; /* root directory start cluster */
|
||||
uint16_t bpbFSInfo; /* [-i] file system info sector */
|
||||
uint16_t bpbBackup; /* [-k] backup boot sector */
|
||||
};
|
||||
.Ed
|
||||
.Sh LIMITATION
|
||||
The maximum file size is 4GB, even if the file system itself is bigger.
|
||||
.Sh EXIT STATUS
|
||||
Exit status is 0 on success and 1 on error.
|
||||
.Sh EXAMPLES
|
||||
Create a file system, using default parameters, on
|
||||
.Pa /dev/ada0s1 :
|
||||
.Bd -literal -offset indent
|
||||
newfs_msdos /dev/ada0s1
|
||||
.Ed
|
||||
.Pp
|
||||
Create a standard 1.44M file system, with volume label
|
||||
.Ar foo ,
|
||||
on
|
||||
.Pa /dev/fd0 :
|
||||
.Bd -literal -offset indent
|
||||
newfs_msdos -f 1440 -L foo fd0
|
||||
.Ed
|
||||
.Pp
|
||||
Create a 30MB image file, with the FAT partition starting
|
||||
63 sectors within the image file:
|
||||
.Bd -literal -offset indent
|
||||
newfs_msdos -C 30M -@63s ./somefile
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr gpart 8 ,
|
||||
.Xr newfs 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility first appeared in
|
||||
.Fx 3.0 .
|
||||
.Sh AUTHORS
|
||||
.An Robert Nordier Aq Mt rnordier@FreeBSD.org
|
||||
-281
@@ -1,281 +0,0 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 1998 Robert Nordier
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mkfs_msdos.h"
|
||||
|
||||
#define argto1(arg, lo, msg) argtou(arg, lo, 0xff, msg)
|
||||
#define argto2(arg, lo, msg) argtou(arg, lo, 0xffff, msg)
|
||||
#define argto4(arg, lo, msg) argtou(arg, lo, 0xffffffff, msg)
|
||||
#define argtox(arg, lo, msg) argtou(arg, lo, UINT_MAX, msg)
|
||||
|
||||
static u_int argtou(const char *, u_int, u_int, const char *);
|
||||
static off_t argtooff(const char *, const char *);
|
||||
static void usage(void);
|
||||
|
||||
static time_t
|
||||
get_tstamp(const char *b)
|
||||
{
|
||||
struct stat st;
|
||||
char *eb;
|
||||
long long l;
|
||||
|
||||
if (stat(b, &st) != -1)
|
||||
return (time_t)st.st_mtime;
|
||||
|
||||
errno = 0;
|
||||
l = strtoll(b, &eb, 0);
|
||||
if (b == eb || *eb || errno)
|
||||
errx(EXIT_FAILURE, "Can't parse timestamp '%s'", b);
|
||||
return (time_t)l;
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct a FAT12, FAT16, or FAT32 file system.
|
||||
*/
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
static const char opts[] = "@:NAB:C:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:T:u:";
|
||||
struct msdos_options o;
|
||||
const char *fname, *dtype;
|
||||
char buf[MAXPATHLEN];
|
||||
int ch;
|
||||
|
||||
memset(&o, 0, sizeof(o));
|
||||
|
||||
while ((ch = getopt(argc, argv, opts)) != -1)
|
||||
switch (ch) {
|
||||
case '@':
|
||||
o.offset = argtooff(optarg, "offset");
|
||||
break;
|
||||
case 'N':
|
||||
o.no_create = 1;
|
||||
break;
|
||||
case 'A':
|
||||
o.align = true;
|
||||
break;
|
||||
case 'B':
|
||||
o.bootstrap = optarg;
|
||||
break;
|
||||
case 'C':
|
||||
o.create_size = argtooff(optarg, "create size");
|
||||
break;
|
||||
case 'F':
|
||||
if (strcmp(optarg, "12") &&
|
||||
strcmp(optarg, "16") &&
|
||||
strcmp(optarg, "32"))
|
||||
errx(1, "%s: bad FAT type", optarg);
|
||||
o.fat_type = atoi(optarg);
|
||||
break;
|
||||
case 'I':
|
||||
o.volume_id = argto4(optarg, 0, "volume ID");
|
||||
o.volume_id_set = 1;
|
||||
break;
|
||||
case 'L':
|
||||
o.volume_label = optarg;
|
||||
break;
|
||||
case 'O':
|
||||
o.OEM_string = optarg;
|
||||
break;
|
||||
case 'S':
|
||||
o.bytes_per_sector = argto2(optarg, 1, "bytes/sector");
|
||||
break;
|
||||
case 'a':
|
||||
o.sectors_per_fat = argto4(optarg, 1, "sectors/FAT");
|
||||
break;
|
||||
case 'b':
|
||||
o.block_size = argtox(optarg, 1, "block size");
|
||||
o.sectors_per_cluster = 0;
|
||||
break;
|
||||
case 'c':
|
||||
o.sectors_per_cluster = argto1(optarg, 1, "sectors/cluster");
|
||||
o.block_size = 0;
|
||||
break;
|
||||
case 'e':
|
||||
o.directory_entries = argto2(optarg, 1, "directory entries");
|
||||
break;
|
||||
case 'f':
|
||||
o.floppy = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
o.drive_heads = argto2(optarg, 1, "drive heads");
|
||||
break;
|
||||
case 'i':
|
||||
o.info_sector = argto2(optarg, 1, "info sector");
|
||||
break;
|
||||
case 'k':
|
||||
o.backup_sector = argto2(optarg, 1, "backup sector");
|
||||
break;
|
||||
case 'm':
|
||||
o.media_descriptor = argto1(optarg, 0, "media descriptor");
|
||||
o.media_descriptor_set = 1;
|
||||
break;
|
||||
case 'n':
|
||||
o.num_FAT = argto1(optarg, 1, "number of FATs");
|
||||
break;
|
||||
case 'o':
|
||||
o.hidden_sectors = argto4(optarg, 0, "hidden sectors");
|
||||
o.hidden_sectors_set = 1;
|
||||
break;
|
||||
case 'r':
|
||||
o.reserved_sectors = argto2(optarg, 1, "reserved sectors");
|
||||
break;
|
||||
case 's':
|
||||
o.size = argto4(optarg, 1, "file system size");
|
||||
break;
|
||||
case 'T':
|
||||
o.timestamp_set = 1;
|
||||
o.timestamp = get_tstamp(optarg);
|
||||
break;
|
||||
case 'u':
|
||||
o.sectors_per_track = argto2(optarg, 1, "sectors/track");
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc < 1 || argc > 2)
|
||||
usage();
|
||||
if (o.align) {
|
||||
if (o.reserved_sectors)
|
||||
errx(1, "align (-A) is incompatible with -r");
|
||||
}
|
||||
fname = *argv++;
|
||||
if (!o.create_size && !strchr(fname, '/')) {
|
||||
snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);
|
||||
fname = buf;
|
||||
}
|
||||
dtype = *argv;
|
||||
exit(!!mkfs_msdos(fname, dtype, &o));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert and check a numeric option argument.
|
||||
*/
|
||||
static u_int
|
||||
argtou(const char *arg, u_int lo, u_int hi, const char *msg)
|
||||
{
|
||||
char *s;
|
||||
u_long x;
|
||||
|
||||
errno = 0;
|
||||
x = strtoul(arg, &s, 0);
|
||||
if (errno || !*arg || *s || x < lo || x > hi)
|
||||
errx(1, "%s: bad %s", arg, msg);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
* Same for off_t, with optional skmgpP suffix
|
||||
*/
|
||||
static off_t
|
||||
argtooff(const char *arg, const char *msg)
|
||||
{
|
||||
char *s;
|
||||
off_t x;
|
||||
|
||||
errno = 0;
|
||||
x = strtoll(arg, &s, 0);
|
||||
/* allow at most one extra char */
|
||||
if (errno || x < 0 || (s[0] && s[1]) )
|
||||
errx(1, "%s: bad %s", arg, msg);
|
||||
if (*s) { /* the extra char is the multiplier */
|
||||
switch (*s) {
|
||||
default:
|
||||
errx(1, "%s: bad %s", arg, msg);
|
||||
/* notreached */
|
||||
|
||||
case 's': /* sector */
|
||||
case 'S':
|
||||
x <<= 9; /* times 512 */
|
||||
break;
|
||||
|
||||
case 'k': /* kilobyte */
|
||||
case 'K':
|
||||
x <<= 10; /* times 1024 */
|
||||
break;
|
||||
|
||||
case 'm': /* megabyte */
|
||||
case 'M':
|
||||
x <<= 20; /* times 1024*1024 */
|
||||
break;
|
||||
|
||||
case 'g': /* gigabyte */
|
||||
case 'G':
|
||||
x <<= 30; /* times 1024*1024*1024 */
|
||||
break;
|
||||
|
||||
case 'p': /* partition start */
|
||||
case 'P':
|
||||
case 'l': /* partition length */
|
||||
case 'L':
|
||||
errx(1, "%s: not supported yet %s", arg, msg);
|
||||
/* notreached */
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print usage message.
|
||||
*/
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: [ -options ] special [disktype]\n");
|
||||
fprintf(stderr, "where the options are:\n");
|
||||
static struct {
|
||||
char o;
|
||||
const char *h;
|
||||
} opts[] = {
|
||||
#define AOPT(_opt, _type, _name, _min, _desc) { _opt, _desc },
|
||||
ALLOPTS
|
||||
#undef AOPT
|
||||
};
|
||||
for (size_t i = 0; i < nitems(opts); i++)
|
||||
fprintf(stderr, "\t-%c %s\n", opts[i].o, opts[i].h);
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user