aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/vtbl.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-07-13 14:47:47 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-07-24 06:34:46 -0400
commitf40ac9cdf6991287f19bdafe9b0752ee40137908 (patch)
treea49120d5be3729feaa40880962f29e3679c1800e /drivers/mtd/ubi/vtbl.c
parentc8566350a3229ca505b84313c65d1403b4d0cbfc (diff)
UBI: implement multiple volumes rename
Quite useful ioctl which allows to make atomic system upgrades. The idea belongs to Richard Titmuss <richard_titmuss@logitech.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/vtbl.c')
-rw-r--r--drivers/mtd/ubi/vtbl.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 05fb72fd268f..23c5376234b2 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -115,6 +115,57 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
115} 115}
116 116
117/** 117/**
118 * ubi_vtbl_rename_volumes - rename UBI volumes in the volume table.
119 * @ubi: UBI device description object
120 * @renam_list: list of &struct ubi_rename_entry objects
121 *
122 * This function re-names multiple volumes specified in @req in the volume
123 * table. Returns zero in case of success and a negative error code in case of
124 * failure.
125 */
126int ubi_vtbl_rename_volumes(struct ubi_device *ubi,
127 struct list_head *rename_list)
128{
129 int i, err;
130 struct ubi_rename_entry *re;
131 struct ubi_volume *layout_vol;
132
133 list_for_each_entry(re, rename_list, list) {
134 uint32_t crc;
135 struct ubi_volume *vol = re->desc->vol;
136 struct ubi_vtbl_record *vtbl_rec = &ubi->vtbl[vol->vol_id];
137
138 if (re->remove) {
139 memcpy(vtbl_rec, &empty_vtbl_record,
140 sizeof(struct ubi_vtbl_record));
141 continue;
142 }
143
144 vtbl_rec->name_len = cpu_to_be16(re->new_name_len);
145 memcpy(vtbl_rec->name, re->new_name, re->new_name_len);
146 memset(vtbl_rec->name + re->new_name_len, 0,
147 UBI_VOL_NAME_MAX + 1 - re->new_name_len);
148 crc = crc32(UBI_CRC32_INIT, vtbl_rec,
149 UBI_VTBL_RECORD_SIZE_CRC);
150 vtbl_rec->crc = cpu_to_be32(crc);
151 }
152
153 layout_vol = ubi->volumes[vol_id2idx(ubi, UBI_LAYOUT_VOLUME_ID)];
154 for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) {
155 err = ubi_eba_unmap_leb(ubi, layout_vol, i);
156 if (err)
157 return err;
158
159 err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0,
160 ubi->vtbl_size, UBI_LONGTERM);
161 if (err)
162 return err;
163 }
164
165 return 0;
166}
167
168/**
118 * vtbl_check - check if volume table is not corrupted and contains sensible 169 * vtbl_check - check if volume table is not corrupted and contains sensible
119 * data. 170 * data.
120 * @ubi: UBI device description object 171 * @ubi: UBI device description object