summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/devfs-core.c3
-rw-r--r--fs/devfs.c3
-rw-r--r--fs/fat/fat.c3
-rw-r--r--fs/fat/ff.c37
-rw-r--r--fs/fs.c9
-rw-r--r--fs/nfs.c3
-rw-r--r--fs/ramfs.c3
-rw-r--r--fs/tftp.c3
8 files changed, 25 insertions, 39 deletions
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index cdb8f79336..2788fe7e7a 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -15,9 +15,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <common.h>
#include <complete.h>
diff --git a/fs/devfs.c b/fs/devfs.c
index fccf25a721..f089c6f9ba 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -15,9 +15,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <common.h>
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 01724a234f..871fe4b4e1 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -15,9 +15,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <common.h>
diff --git a/fs/fat/ff.c b/fs/fat/ff.c
index 66db1d6b50..33f8b6195d 100644
--- a/fs/fat/ff.c
+++ b/fs/fat/ff.c
@@ -93,6 +93,7 @@
#include <errno.h>
#include <malloc.h>
#include <linux/ctype.h>
+#include <filetype.h>
#include "ff.h" /* FatFs configurations and declarations */
#include "diskio.h" /* Declarations of low level disk I/O functions */
@@ -1531,29 +1532,20 @@ int follow_path ( /* 0(0): successful, !=0: error code */
/*
* Load boot record and check if it is an FAT boot record
*/
-static int check_fs ( /* 0:The FAT BR, 1:Valid BR but not an FAT, 2:Not a BR, 3:Disk error */
+static enum filetype check_fs ( /* 0:The FAT BR, 1:Valid BR but not an FAT, 2:Not a BR, 3:Disk error */
FATFS *fs, /* File system object */
- DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */
+ DWORD sect, /* Sector# (lba) to check if it is an FAT boot record or not */
+ DWORD *bootsec
)
{
- int ret;
+ enum filetype ret;
/* Load boot record */
ret = disk_read(fs, fs->win, sect, 1);
if (ret)
- return ret;
- /* Check record signature (always placed at offset 510 even if the sector size is>512) */
- if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55)
- return -ENODEV;
-
- /* Check "FAT" string */
- if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146)
- return 0;
-
- if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146)
- return 0;
+ return filetype_unknown;
- return -ENODEV;
+ return is_fat_or_mbr(fs->win, bootsec);
}
/*
@@ -1565,8 +1557,10 @@ static int chk_mounted ( /* 0(0): successful, !=0: any error occurred */
)
{
BYTE fmt, b;
+ DWORD first_boot_sect;
DWORD bsect, fasize, tsect, sysect, nclst, szbfat;
WORD nrsv;
+ enum filetype type;
INIT_LIST_HEAD(&fs->dirtylist);
@@ -1579,9 +1573,16 @@ static int chk_mounted ( /* 0(0): successful, !=0: any error occurred */
return -EIO;
#endif
/* Search FAT partition on the drive. Supports only generic partitionings, FDISK and SFD. */
- fmt = check_fs(fs, bsect = 0); /* Check sector 0 if it is a VBR */
- if (fmt)
- return fmt; /* No FAT volume is found */
+ type = check_fs(fs, bsect = 0, &first_boot_sect); /* Check sector 0 if it is a VBR */
+ if (type == filetype_mbr) {
+ /* Sector 0 is an MBR, now check for FAT in the first partition */
+ type = check_fs(fs, bsect = first_boot_sect, NULL);
+ if (type != filetype_fat)
+ return -ENODEV;
+ }
+
+ if (type == filetype_unknown)
+ return -ENODEV;
/* Following code initializes the file system object */
diff --git a/fs/fs.c b/fs/fs.c
index db4621a40d..b9a1f17dfc 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -15,9 +15,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <common.h>
@@ -1141,6 +1138,12 @@ struct bus_type fs_bus = {
.remove = fs_remove,
};
+static int fs_bus_init(void)
+{
+ return bus_register(&fs_bus);
+}
+pure_initcall(fs_bus_init);
+
int register_fs_driver(struct fs_driver_d *fsdrv)
{
fsdrv->drv.bus = &fs_bus;
diff --git a/fs/nfs.c b/fs/nfs.c
index 797e3bd471..7173264351 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -18,9 +18,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <common.h>
diff --git a/fs/ramfs.c b/fs/ramfs.c
index 8f3b936685..f45a45491f 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -15,9 +15,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <common.h>
diff --git a/fs/tftp.c b/fs/tftp.c
index b58d6fcf56..ae57f95300 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -15,9 +15,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <common.h>
#include <command.h>