I noticed that JFFS2 allows the mounting of MTD devices by their
partition names, rather than their numbers. This is handy sometimes if
you cannot be sure which order your partitions are going to come up in
(for removable devices etc...) or if people are using command line
partitioning.
I've fiddled that code into yaffs, with one minor change - JFFS2 uses
':' to delimit the partition name, that is:
mount -t jffs2 mtd:PartitionName /mnt
However busybox assumes that any mount device containing a ':' is an NFS
mount, and changes the type to nfs even if you explicitly set it. To
avoid this I've used '.' instead, ie:
mount -t yaffs mtd.PartitionName /mnt
I'm not sure if anyone else would find this useful or not, but I've
attached the patch if so.
--
Bluewater Systems Ltd - ARM Technology Solutions Centre
Andre Renaud Bluewater Systems Ltd
Phone: +64 3 3779127 (Aus 1 800 148 751) Level 17, 119 Armagh St
Fax: +64 3 3779135 PO Box 13889
Email: arenaud@bluewatersys.com Christchurch
Web: http://www.bluewatersys.com New Zealand
diff -uw yaffs2.orig/yaffs_fs.c yaffs2/yaffs_fs.c
--- yaffs2.orig/yaffs_fs.c 2006-08-25 15:48:39.000000000 +1200
+++ yaffs2/yaffs_fs.c 2006-08-25 15:54:42.000000000 +1200
@@ -1667,6 +1667,29 @@
return sb;
}
+/*
+ * Converts mtd partition names like "mtd.PartiaionNAme" into /dev/mtdblockX so that
+ * we can mount by partition name rather than block number
+ * Returns 1 on success
+ */
+static int mtd_name_to_block_name (const char *dev_name, char *block_name, int max_len)
+{
+ int mtdnr;
+
+ if (dev_name[0] == 'm' && dev_name[1] == 't' && dev_name[2] == 'd' && dev_name[3] == '.') {
+ for (mtdnr = 0; mtdnr < MAX_MTD_DEVICES; mtdnr++) {
+ struct mtd_info *mtd = get_mtd_device (NULL, mtdnr);
+ if (mtd) {
+ if (!strcmp (mtd->name, dev_name + 4)) {
+ snprintf (block_name, max_len, "/dev/mtdblock%d", mtdnr);
+ return 1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
static int yaffs_internal_read_super_mtd(struct super_block *sb, void *data,
@@ -1679,6 +1702,10 @@
int flags, const char *dev_name,
void *data)
{
+ char new_blockname[20];
+
+ if (mtd_name_to_block_name (dev_name, new_blockname, 20))
+ dev_name = new_blockname;
return get_sb_bdev(fs, flags, dev_name, data,
yaffs_internal_read_super_mtd);
@@ -1716,6 +1743,10 @@
int flags, const char *dev_name,
void *data)
{
+ char new_blockname[20];
+
+ if (mtd_name_to_block_name (dev_name, new_blockname, 20))
+ dev_name = new_blockname;
return get_sb_bdev(fs, flags, dev_name, data,
yaffs2_internal_read_super_mtd);