diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-11-28 08:11:13 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-11-28 08:11:13 -0600 |
commit | 382a7012f3613df64b49a018dd8b4644745d6b01 (patch) | |
tree | 4da197831771e53cf75b611b33289578c63fdb6b /nuttx/drivers/mtd | |
parent | 0523e9f8b4ee025e42d520409618d11bb7a4bc1a (diff) | |
download | px4-nuttx-382a7012f3613df64b49a018dd8b4644745d6b01.tar.gz px4-nuttx-382a7012f3613df64b49a018dd8b4644745d6b01.tar.bz2 px4-nuttx-382a7012f3613df64b49a018dd8b4644745d6b01.zip |
Fix error in SMARTFS partition number reporting
Diffstat (limited to 'nuttx/drivers/mtd')
-rw-r--r-- | nuttx/drivers/mtd/smart.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/nuttx/drivers/mtd/smart.c b/nuttx/drivers/mtd/smart.c index a6c8fa2c2..542129a2e 100644 --- a/nuttx/drivers/mtd/smart.c +++ b/nuttx/drivers/mtd/smart.c @@ -96,6 +96,7 @@ #define SMARTFS_FMT_AGING_POS 32 #define SMART_FMT_VERSION 1 +#define SMART_PARTNAME_SIZE 4 #define SMART_FIRST_ALLOC_SECTOR 12 /* First logical sector number we will * use for assignment of requested Alloc @@ -134,7 +135,7 @@ struct smart_struct_s FAR uint8_t *releasecount; /* Count of released sectors per erase block */ FAR uint8_t *freecount; /* Count of free sectors per erase block */ FAR char *rwbuffer; /* Our sector read/write buffer */ - const FAR char *partname; /* Optional partition name */ + char partname[SMART_PARTNAME_SIZE]; /* Optional partition name */ uint8_t formatversion; /* Format version on the device */ uint8_t formatstatus; /* Indicates the status of the device format */ uint8_t namesize; /* Length of filenames on this device */ @@ -804,9 +805,9 @@ static int smart_scan(struct smart_struct_s *dev) for (x = 1; x < dev->rootdirentries; x++) { - if (dev->partname != NULL) + if (dev->partname[0] != '\0') { - snprintf(dev->rwbuffer, sizeof(devname), "/dev/smart%d%s%d", + snprintf(dev->rwbuffer, sizeof(devname), "/dev/smart%d%sd%d", dev->minor, dev->partname, x+1); } else @@ -2158,7 +2159,15 @@ int smart_initialize(int minor, FAR struct mtd_dev_s *mtd, const char *partname) dev->formatstatus = SMART_FMT_STAT_UNKNOWN; dev->namesize = CONFIG_SMARTFS_MAXNAMLEN; - dev->partname = partname; + if (partname) + { + strncpy(dev->partname, partname, SMART_PARTNAME_SIZE); + } + else + { + dev->partname[0] = '\0'; + } + #ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS dev->minor = minor; #endif |