diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libnvram/libnvram.code | 17 | ||||
-rw-r--r-- | lib/libnvram/nvram.c | 16 | ||||
-rw-r--r-- | lib/libnvram/nvram.h | 1 |
3 files changed, 22 insertions, 12 deletions
diff --git a/lib/libnvram/libnvram.code b/lib/libnvram/libnvram.code index 723941d..427adc2 100644 --- a/lib/libnvram/libnvram.code +++ b/lib/libnvram/libnvram.code @@ -103,23 +103,16 @@ MIRP /* new-nvram-partition ( type name.addr name.len len -- part.offs part.len FALSE | TRUE) */ PRIM(new_X2d_nvram_X2d_partition) - int type, len, i, slen; - char name[12], *addr; + int type, len, namelen; partition_t partition; + char *name; len = TOS.u; POP; - slen = TOS.u; POP; - addr = (char *)TOS.u; POP; + namelen = TOS.u; POP; + name = (char *)TOS.u; POP; type = TOS.u; POP; - for (i=0; i<12; i++) { - if(slen>i) - name[i]=addr[i]; - else - name[i]=0; - } - - partition=new_nvram_partition(type, name, len); + partition = new_nvram_partition_fs(type, name, namelen, len); if(!partition.len) { PUSH; TOS.u = -1; // TRUE diff --git a/lib/libnvram/nvram.c b/lib/libnvram/nvram.c index 5c11376..1a4f91a 100644 --- a/lib/libnvram/nvram.c +++ b/lib/libnvram/nvram.c @@ -466,6 +466,22 @@ partition_t new_nvram_partition(int type, char *name, int len) return new_part; } +partition_t new_nvram_partition_fs(int type, char *name, int namelen, int len) +{ + char buf[13]; + int i; + + for (i = 0; i < 12; i++) { + if (i < namelen) + buf[i] = name[i]; + else + buf[i] = 0; + } + buf[12] = 0; + + return new_nvram_partition(type, buf, len); +} + /** * @param partition partition structure pointing to the partition to wipe. */ diff --git a/lib/libnvram/nvram.h b/lib/libnvram/nvram.h index fa6bdd4..b4964f6 100644 --- a/lib/libnvram/nvram.h +++ b/lib/libnvram/nvram.h @@ -54,6 +54,7 @@ partition_t get_partition(unsigned int type, char *name); void erase_nvram(int offset, int len); int wipe_partition(partition_t partition, int header_only); partition_t new_nvram_partition(int type, char *name, int len); +partition_t new_nvram_partition_fs(int type, char *name, int namelen, int len); int increase_nvram_partition_size(partition_t partition, int newsize); int clear_nvram_partition(partition_t part); int delete_nvram_partition(partition_t part); |