23 #include <linux/module.h>
25 #include <linux/slab.h>
28 #include <asm/div64.h>
134 dbg_gen(
"open device %d, volume %d, mode %d", ubi_num, vol_id, mode);
150 if (vol_id < 0 || vol_id >= ubi->
vtbl_slots) {
207 ubi_warn(
"volume %d on UBI device %d is corrupted",
224 ubi_err(
"cannot open device %d, volume %d, error %d",
225 ubi_num, vol_id, err);
245 dbg_gen(
"open device %d, volume %s, mode %d", ubi_num, name, mode);
301 dbg_gen(
"open volume %s, mode %d", pathname, mode);
303 if (!pathname || !*pathname)
308 return ERR_PTR(error);
310 inode = path.
dentry->d_inode;
313 vol_id = iminor(inode) - 1;
318 if (vol_id >= 0 && ubi_num >= 0)
333 dbg_gen(
"close device %d, volume %d, mode %d",
337 switch (desc->
mode) {
391 dbg_gen(
"read %d bytes from LEB %d:%d:%d", len, vol_id, lnum, offset);
393 if (vol_id < 0 || vol_id >= ubi->
vtbl_slots || lnum < 0 ||
394 lnum >= vol->
used_ebs || offset < 0 || len < 0 ||
414 ubi_warn(
"mark volume %d as corrupted", vol_id);
454 dbg_gen(
"write %d bytes to LEB %d:%d:%d", len, vol_id, lnum, offset);
462 if (lnum < 0 || lnum >= vol->
reserved_pebs || offset < 0 || len < 0 ||
499 dbg_gen(
"atomically write %d bytes to LEB %d:%d", len, vol_id, lnum);
681 return vol->
eba_tbl[lnum] >= 0;