本文整理汇总了C++中JFFS2_SUMMARY_DIRENT_SIZE函数的典型用法代码示例。如果您正苦于以下问题:C++ JFFS2_SUMMARY_DIRENT_SIZE函数的具体用法?C++ JFFS2_SUMMARY_DIRENT_SIZE怎么用?C++ JFFS2_SUMMARY_DIRENT_SIZE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JFFS2_SUMMARY_DIRENT_SIZE函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: jffs2_sum_add_mem
static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item)
{
if (!s->sum_list_head)
s->sum_list_head = (union jffs2_sum_mem *) item;
if (s->sum_list_tail)
s->sum_list_tail->u.next = (union jffs2_sum_mem *) item;
s->sum_list_tail = (union jffs2_sum_mem *) item;
switch (je16_to_cpu(item->u.nodetype)) {
case JFFS2_NODETYPE_INODE:
s->sum_size += JFFS2_SUMMARY_INODE_SIZE;
s->sum_num++;
dbg_summary("inode (%u) added to summary\n",
je32_to_cpu(item->i.inode));
break;
case JFFS2_NODETYPE_DIRENT:
s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize);
s->sum_num++;
dbg_summary("dirent (%u) added to summary\n",
je32_to_cpu(item->d.ino));
break;
default:
JFFS2_WARNING("UNKNOWN node type %u\n",
je16_to_cpu(item->u.nodetype));
return 1;
}
return 0;
}
开发者ID:nighthawk149,项目名称:fvs318g-cfw,代码行数:28,代码来源:summary.c
示例2: write_dirent_to_buff
void write_dirent_to_buff(union jffs2_node_union *node)
{
pad_block_if_less_than(je32_to_cpu (node->d.totlen),JFFS2_SUMMARY_DIRENT_SIZE(node->d.nsize));
add_sum_dirent_mem(node);
full_write(data_buffer + data_ofs, &(node->d), je32_to_cpu (node->d.totlen));
padword();
}
开发者ID:DentonGentry,项目名称:gfiber-gfrg100,代码行数:7,代码来源:sumtool.c
示例3: add_sum_mem
int add_sum_mem(union jffs2_sum_mem *item)
{
if (!sum_collected->sum_list_head)
sum_collected->sum_list_head = (union jffs2_sum_mem *) item;
if (sum_collected->sum_list_tail)
sum_collected->sum_list_tail->u.next = (union jffs2_sum_mem *) item;
sum_collected->sum_list_tail = (union jffs2_sum_mem *) item;
switch (je16_to_cpu(item->u.nodetype)) {
case JFFS2_NODETYPE_INODE:
sum_collected->sum_size += JFFS2_SUMMARY_INODE_SIZE;
sum_collected->sum_num++;
break;
case JFFS2_NODETYPE_DIRENT:
sum_collected->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize);
sum_collected->sum_num++;
break;
case JFFS2_NODETYPE_XATTR:
sum_collected->sum_size += JFFS2_SUMMARY_XATTR_SIZE;
sum_collected->sum_num++;
break;
case JFFS2_NODETYPE_XREF:
sum_collected->sum_size += JFFS2_SUMMARY_XREF_SIZE;
sum_collected->sum_num++;
break;
default:
error_msg_and_die("__jffs2_add_sum_mem(): UNKNOWN node type %d\n", je16_to_cpu(item->u.nodetype));
}
return 0;
}
开发者ID:DentonGentry,项目名称:gfiber-gfrg100,代码行数:35,代码来源:sumtool.c
示例4: jffs2_sum_add_mem
static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item)
{
if (!s->sum_list_head)
s->sum_list_head = (union jffs2_sum_mem *) item;
if (s->sum_list_tail)
s->sum_list_tail->u.next = (union jffs2_sum_mem *) item;
s->sum_list_tail = (union jffs2_sum_mem *) item;
switch (je16_to_cpu(item->u.nodetype)) {
case JFFS2_NODETYPE_INODE:
s->sum_size += JFFS2_SUMMARY_INODE_SIZE;
s->sum_num++;
dbg_summary("inode (%u) added to summary\n",
je32_to_cpu(item->i.inode));
break;
case JFFS2_NODETYPE_DIRENT:
s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize);
s->sum_num++;
dbg_summary("dirent (%u) added to summary\n",
je32_to_cpu(item->d.ino));
break;
#ifdef CONFIG_JFFS2_FS_XATTR
case JFFS2_NODETYPE_XATTR:
s->sum_size += JFFS2_SUMMARY_XATTR_SIZE;
s->sum_num++;
dbg_summary("xattr (xid=%u, version=%u) added to summary\n",
je32_to_cpu(item->x.xid), je32_to_cpu(item->x.version));
break;
case JFFS2_NODETYPE_XREF:
s->sum_size += JFFS2_SUMMARY_XREF_SIZE;
s->sum_num++;
dbg_summary("xref added to summary\n");
break;
#endif
default:
JFFS2_WARNING("UNKNOWN node type %u\n",
je16_to_cpu(item->u.nodetype));
return 1;
}
return 0;
}
开发者ID:AK101111,项目名称:linux,代码行数:41,代码来源:summary.c
示例5: do_dumpcontent
//.........这里部分代码省略.........
for(i=0; i<je32_to_cpu(node->s.sum_num); i++) {
switch(je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) {
case JFFS2_NODETYPE_INODE : {
struct jffs2_sum_inode_flash *spi;
spi = sp;
printf ("%14s #ino %5d, version %5d, offset 0x%08x, totlen 0x%08x\n",
"",
je32_to_cpu (spi->inode),
je32_to_cpu (spi->version),
je32_to_cpu (spi->offset),
je32_to_cpu (spi->totlen));
sp += JFFS2_SUMMARY_INODE_SIZE;
break;
}
case JFFS2_NODETYPE_DIRENT : {
char name[255];
struct jffs2_sum_dirent_flash *spd;
spd = sp;
memcpy(name,spd->name,spd->nsize);
name [spd->nsize] = 0x0;
printf ("%14s dirent offset 0x%08x, totlen 0x%08x, #pino %5d, version %5d, #ino %8d, nsize %8d, name %s \n",
"",
je32_to_cpu (spd->offset),
je32_to_cpu (spd->totlen),
je32_to_cpu (spd->pino),
je32_to_cpu (spd->version),
je32_to_cpu (spd->ino),
spd->nsize,
name);
sp += JFFS2_SUMMARY_DIRENT_SIZE(spd->nsize);
break;
}
default :
printf("Unknown summary node!\n");
break;
}
}
sm = (struct jffs2_sum_marker *) ((char *)p + je32_to_cpu(node->s.totlen) - sizeof(struct jffs2_sum_marker));
printf("%14s Sum Node Offset 0x%08x, Magic 0x%08x, Padded size 0x%08x\n",
"",
je32_to_cpu(sm->offset),
je32_to_cpu(sm->magic),
je32_to_cpu(node->s.padded));
}
p += PAD(je32_to_cpu (node->s.totlen));
break;
}
case JFFS2_NODETYPE_CLEANMARKER:
if (verbose) {
printf ("%8s Cleanmarker at 0x%08x, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - data, je32_to_cpu (node->u.totlen));
}
p += PAD(je32_to_cpu (node->u.totlen));
break;
case JFFS2_NODETYPE_PADDING:
if (verbose) {
printf ("%8s Padding node at 0x%08x, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - data, je32_to_cpu (node->u.totlen));
}
p += PAD(je32_to_cpu (node->u.totlen));
break;
case 0xffff:
p += 4;
empty += 4;
break;
default:
if (verbose) {
printf ("%8s Unknown node at 0x%08x, totlen 0x%08x\n",
obsolete ? "Obsolete" : "",
p - data, je32_to_cpu (node->u.totlen));
}
p += PAD(je32_to_cpu (node->u.totlen));
dirty += PAD(je32_to_cpu (node->u.totlen));
}
}
if (verbose)
printf ("Empty space: %d, dirty space: %d\n", empty, dirty);
}
开发者ID:berte,项目名称:mediaplayer,代码行数:101,代码来源:jffs2dump.c
示例6: jffs2_mknod
static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, dev_t rdev)
{
struct jffs2_inode_info *f, *dir_f;
struct jffs2_sb_info *c;
struct inode *inode;
struct jffs2_raw_inode *ri;
struct jffs2_raw_dirent *rd;
struct jffs2_full_dnode *fn;
struct jffs2_full_dirent *fd;
int namelen;
union jffs2_device_node dev;
int devlen = 0;
uint32_t alloclen;
int ret;
if (!new_valid_dev(rdev))
return -EINVAL;
ri = jffs2_alloc_raw_inode();
if (!ri)
return -ENOMEM;
c = JFFS2_SB_INFO(dir_i->i_sb);
if (S_ISBLK(mode) || S_ISCHR(mode))
devlen = jffs2_encode_dev(&dev, rdev);
/* Try to reserve enough space for both node and dirent.
* Just the node will do for now, though
*/
namelen = dentry->d_name.len;
ret = jffs2_reserve_space(c, sizeof(*ri) + devlen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
if (ret) {
jffs2_free_raw_inode(ri);
return ret;
}
inode = jffs2_new_inode(dir_i, mode, ri);
if (IS_ERR(inode)) {
jffs2_free_raw_inode(ri);
jffs2_complete_reservation(c);
return PTR_ERR(inode);
}
inode->i_op = &jffs2_file_inode_operations;
init_special_inode(inode, inode->i_mode, rdev);
f = JFFS2_INODE_INFO(inode);
ri->dsize = ri->csize = cpu_to_je32(devlen);
ri->totlen = cpu_to_je32(sizeof(*ri) + devlen);
ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));
ri->compr = JFFS2_COMPR_NONE;
ri->data_crc = cpu_to_je32(crc32(0, &dev, devlen));
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
fn = jffs2_write_dnode(c, f, ri, (char *)&dev, devlen, ALLOC_NORMAL);
jffs2_free_raw_inode(ri);
if (IS_ERR(fn)) {
/* Eeek. Wave bye bye */
mutex_unlock(&f->sem);
jffs2_complete_reservation(c);
ret = PTR_ERR(fn);
goto fail;
}
/* No data here. Only a metadata node, which will be
obsoleted by the first data write
*/
f->metadata = fn;
mutex_unlock(&f->sem);
jffs2_complete_reservation(c);
ret = jffs2_init_security(inode, dir_i, &dentry->d_name);
if (ret)
goto fail;
ret = jffs2_init_acl_post(inode);
if (ret)
goto fail;
ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
if (ret)
goto fail;
rd = jffs2_alloc_raw_dirent();
if (!rd) {
/* Argh. Now we treat it like a normal delete */
jffs2_complete_reservation(c);
ret = -ENOMEM;
goto fail;
}
dir_f = JFFS2_INODE_INFO(dir_i);
//.........这里部分代码省略.........
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:101,代码来源:dir.c
示例7: jffs2_mkdir
static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
{
struct jffs2_inode_info *f, *dir_f;
struct jffs2_sb_info *c;
struct inode *inode;
struct jffs2_raw_inode *ri;
struct jffs2_raw_dirent *rd;
struct jffs2_full_dnode *fn;
struct jffs2_full_dirent *fd;
int namelen;
uint32_t alloclen;
int ret;
mode |= S_IFDIR;
ri = jffs2_alloc_raw_inode();
if (!ri)
return -ENOMEM;
c = JFFS2_SB_INFO(dir_i->i_sb);
/* Try to reserve enough space for both node and dirent.
* Just the node will do for now, though
*/
namelen = dentry->d_name.len;
ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL,
JFFS2_SUMMARY_INODE_SIZE);
if (ret) {
jffs2_free_raw_inode(ri);
return ret;
}
inode = jffs2_new_inode(dir_i, mode, ri);
if (IS_ERR(inode)) {
jffs2_free_raw_inode(ri);
jffs2_complete_reservation(c);
return PTR_ERR(inode);
}
inode->i_op = &jffs2_dir_inode_operations;
inode->i_fop = &jffs2_dir_operations;
f = JFFS2_INODE_INFO(inode);
/* Directories get nlink 2 at start */
inode->i_nlink = 2;
/* but ic->pino_nlink is the parent ino# */
f->inocache->pino_nlink = dir_i->i_ino;
ri->data_crc = cpu_to_je32(0);
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL);
jffs2_free_raw_inode(ri);
if (IS_ERR(fn)) {
/* Eeek. Wave bye bye */
mutex_unlock(&f->sem);
jffs2_complete_reservation(c);
ret = PTR_ERR(fn);
goto fail;
}
/* No data here. Only a metadata node, which will be
obsoleted by the first data write
*/
f->metadata = fn;
mutex_unlock(&f->sem);
jffs2_complete_reservation(c);
ret = jffs2_init_security(inode, dir_i, &dentry->d_name);
if (ret)
goto fail;
ret = jffs2_init_acl_post(inode);
if (ret)
goto fail;
ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
if (ret)
goto fail;
rd = jffs2_alloc_raw_dirent();
if (!rd) {
/* Argh. Now we treat it like a normal delete */
jffs2_complete_reservation(c);
ret = -ENOMEM;
goto fail;
}
dir_f = JFFS2_INODE_INFO(dir_i);
mutex_lock(&dir_f->sem);
rd->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
rd->nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT);
rd->totlen = cpu_to_je32(sizeof(*rd) + namelen);
//.........这里部分代码省略.........
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:101,代码来源:dir.c
示例8: jffs2_symlink
static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char *target)
{
struct jffs2_inode_info *f, *dir_f;
struct jffs2_sb_info *c;
struct inode *inode;
struct jffs2_raw_inode *ri;
struct jffs2_raw_dirent *rd;
struct jffs2_full_dnode *fn;
struct jffs2_full_dirent *fd;
int namelen;
uint32_t alloclen;
int ret, targetlen = strlen(target);
/* FIXME: If you care. We'd need to use frags for the target
if it grows much more than this */
if (targetlen > 254)
return -ENAMETOOLONG;
ri = jffs2_alloc_raw_inode();
if (!ri)
return -ENOMEM;
c = JFFS2_SB_INFO(dir_i->i_sb);
/* Try to reserve enough space for both node and dirent.
* Just the node will do for now, though
*/
namelen = dentry->d_name.len;
ret = jffs2_reserve_space(c, sizeof(*ri) + targetlen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
if (ret) {
jffs2_free_raw_inode(ri);
return ret;
}
inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri);
if (IS_ERR(inode)) {
jffs2_free_raw_inode(ri);
jffs2_complete_reservation(c);
return PTR_ERR(inode);
}
inode->i_op = &jffs2_symlink_inode_operations;
f = JFFS2_INODE_INFO(inode);
inode->i_size = targetlen;
ri->isize = ri->dsize = ri->csize = cpu_to_je32(inode->i_size);
ri->totlen = cpu_to_je32(sizeof(*ri) + inode->i_size);
ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));
ri->compr = JFFS2_COMPR_NONE;
ri->data_crc = cpu_to_je32(crc32(0, target, targetlen));
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
fn = jffs2_write_dnode(c, f, ri, target, targetlen, ALLOC_NORMAL);
jffs2_free_raw_inode(ri);
if (IS_ERR(fn)) {
/* Eeek. Wave bye bye */
mutex_unlock(&f->sem);
jffs2_complete_reservation(c);
ret = PTR_ERR(fn);
goto fail;
}
/* We use f->target field to store the target path. */
f->target = kmemdup(target, targetlen + 1, GFP_KERNEL);
if (!f->target) {
;
mutex_unlock(&f->sem);
jffs2_complete_reservation(c);
ret = -ENOMEM;
goto fail;
}
D1(printk(KERN_DEBUG "jffs2_symlink: symlink's target '%s' cached\n", (char *)f->target));
/* No data here. Only a metadata node, which will be
obsoleted by the first data write
*/
f->metadata = fn;
mutex_unlock(&f->sem);
jffs2_complete_reservation(c);
ret = jffs2_init_security(inode, dir_i, &dentry->d_name);
if (ret)
goto fail;
ret = jffs2_init_acl_post(inode);
if (ret)
goto fail;
ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen,
ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen));
//.........这里部分代码省略.........
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:101,代码来源:dir.c
示例9: jffs2_sum_write_data
static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
uint32_t infosize, uint32_t datasize, int padsize)
{
struct jffs2_raw_summary isum;
union jffs2_sum_mem *temp;
struct jffs2_sum_marker *sm;
struct kvec vecs[2];
uint32_t sum_ofs;
void *wpage;
int ret;
size_t retlen;
if (padsize + datasize > MAX_SUMMARY_SIZE) {
/* It won't fit in the buffer. Abort summary for this jeb */
jffs2_sum_disable_collecting(c->summary);
JFFS2_WARNING("Summary too big (%d data, %d pad) in eraseblock at %08x\n",
datasize, padsize, jeb->offset);
/* Non-fatal */
return 0;
}
/* Is there enough space for summary? */
if (padsize < 0) {
/* don't try to write out summary for this jeb */
jffs2_sum_disable_collecting(c->summary);
JFFS2_WARNING("Not enough space for summary, padsize = %d\n",
padsize);
/* Non-fatal */
return 0;
}
memset(c->summary->sum_buf, 0xff, datasize);
memset(&isum, 0, sizeof(isum));
isum.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
isum.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
isum.totlen = cpu_to_je32(infosize);
isum.hdr_crc = cpu_to_je32(crc32(0, &isum, sizeof(struct jffs2_unknown_node) - 4));
isum.padded = cpu_to_je32(c->summary->sum_padded);
isum.cln_mkr = cpu_to_je32(c->cleanmarker_size);
isum.sum_num = cpu_to_je32(c->summary->sum_num);
wpage = c->summary->sum_buf;
while (c->summary->sum_num) {
temp = c->summary->sum_list_head;
switch (je16_to_cpu(temp->u.nodetype)) {
case JFFS2_NODETYPE_INODE: {
struct jffs2_sum_inode_flash *sino_ptr = wpage;
sino_ptr->nodetype = temp->i.nodetype;
sino_ptr->inode = temp->i.inode;
sino_ptr->version = temp->i.version;
sino_ptr->offset = temp->i.offset;
sino_ptr->totlen = temp->i.totlen;
wpage += JFFS2_SUMMARY_INODE_SIZE;
break;
}
case JFFS2_NODETYPE_DIRENT: {
struct jffs2_sum_dirent_flash *sdrnt_ptr = wpage;
sdrnt_ptr->nodetype = temp->d.nodetype;
sdrnt_ptr->totlen = temp->d.totlen;
sdrnt_ptr->offset = temp->d.offset;
sdrnt_ptr->pino = temp->d.pino;
sdrnt_ptr->version = temp->d.version;
sdrnt_ptr->ino = temp->d.ino;
sdrnt_ptr->nsize = temp->d.nsize;
sdrnt_ptr->type = temp->d.type;
memcpy(sdrnt_ptr->name, temp->d.name,
temp->d.nsize);
wpage += JFFS2_SUMMARY_DIRENT_SIZE(temp->d.nsize);
break;
}
#ifdef CONFIG_JFFS2_FS_XATTR
case JFFS2_NODETYPE_XATTR: {
struct jffs2_sum_xattr_flash *sxattr_ptr = wpage;
temp = c->summary->sum_list_head;
sxattr_ptr->nodetype = temp->x.nodetype;
sxattr_ptr->xid = temp->x.xid;
sxattr_ptr->version = temp->x.version;
sxattr_ptr->offset = temp->x.offset;
sxattr_ptr->totlen = temp->x.totlen;
wpage += JFFS2_SUMMARY_XATTR_SIZE;
break;
}
case JFFS2_NODETYPE_XREF: {
struct jffs2_sum_xref_flash *sxref_ptr = wpage;
temp = c->summary->sum_list_head;
sxref_ptr->nodetype = temp->r.nodetype;
//.........这里部分代码省略.........
开发者ID:AK101111,项目名称:linux,代码行数:101,代码来源:summary.c
示例10: jffs2_sum_process_sum_data
//.........这里部分代码省略.........
pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n",
jeb->offset +
je32_to_cpu(spd->offset),
checkedlen);
}
fd = jffs2_alloc_full_dirent(checkedlen+1);
if (!fd)
return -ENOMEM;
memcpy(&fd->name, spd->name, checkedlen);
fd->name[checkedlen] = 0;
ic = jffs2_scan_make_ino_cache(c, je32_to_cpu(spd->pino));
if (!ic) {
jffs2_free_full_dirent(fd);
return -ENOMEM;
}
fd->raw = sum_link_node_ref(c, jeb, je32_to_cpu(spd->offset) | REF_UNCHECKED,
PAD(je32_to_cpu(spd->totlen)), ic);
fd->next = NULL;
fd->version = je32_to_cpu(spd->version);
fd->ino = je32_to_cpu(spd->ino);
fd->nhash = full_name_hash(NULL, fd->name, checkedlen);
fd->type = spd->type;
jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
*pseudo_random += je32_to_cpu(spd->version);
sp += JFFS2_SUMMARY_DIRENT_SIZE(spd->nsize);
break;
}
#ifdef CONFIG_JFFS2_FS_XATTR
case JFFS2_NODETYPE_XATTR: {
struct jffs2_xattr_datum *xd;
struct jffs2_sum_xattr_flash *spx;
spx = (struct jffs2_sum_xattr_flash *)sp;
dbg_summary("xattr at %#08x-%#08x (xid=%u, version=%u)\n",
jeb->offset + je32_to_cpu(spx->offset),
jeb->offset + je32_to_cpu(spx->offset) + je32_to_cpu(spx->totlen),
je32_to_cpu(spx->xid), je32_to_cpu(spx->version));
xd = jffs2_setup_xattr_datum(c, je32_to_cpu(spx->xid),
je32_to_cpu(spx->version));
if (IS_ERR(xd))
return PTR_ERR(xd);
if (xd->version > je32_to_cpu(spx->version)) {
/* node is not the newest one */
struct jffs2_raw_node_ref *raw
= sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
PAD(je32_to_cpu(spx->totlen)), NULL);
raw->next_in_ino = xd->node->next_in_ino;
xd->node->next_in_ino = raw;
} else {
xd->version = je32_to_cpu(spx->version);
sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
PAD(je32_to_cpu(spx->totlen)), (void *)xd);
}
*pseudo_random += je32_to_cpu(spx->xid);
sp += JFFS2_SUMMARY_XATTR_SIZE;
开发者ID:AK101111,项目名称:linux,代码行数:67,代码来源:summary.c
示例11: jffs2_sum_write_data
static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
uint32_t infosize, uint32_t datasize, int padsize)
{
struct jffs2_raw_summary isum;
union jffs2_sum_mem *temp;
struct jffs2_sum_marker *sm;
struct kvec vecs[2];
void *wpage;
int ret;
size_t retlen;
memset(c->summary->sum_buf, 0xff, datasize);
memset(&isum, 0, sizeof(isum));
isum.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
isum.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
isum.totlen = cpu_to_je32(infosize);
isum.hdr_crc = cpu_to_je32(crc32(0, &isum, sizeof(struct jffs2_unknown_node) - 4));
isum.padded = cpu_to_je32(c->summary->sum_padded);
isum.cln_mkr = cpu_to_je32(c->cleanmarker_size);
isum.sum_num = cpu_to_je32(c->summary->sum_num);
wpage = c->summary->sum_buf;
while (c->summary->sum_num) {
switch (je16_to_cpu(c->summary->sum_list_head->u.nodetype)) {
case JFFS2_NODETYPE_INODE: {
struct jffs2_sum_inode_flash *sino_ptr = wpage;
sino_ptr->nodetype = c->summary->sum_list_head->i.nodetype;
sino_ptr->inode = c->summary->sum_list_head->i.inode;
sino_ptr->version = c->summary->sum_list_head->i.version;
sino_ptr->offset = c->summary->sum_list_head->i.offset;
sino_ptr->totlen = c->summary->sum_list_head->i.totlen;
wpage += JFFS2_SUMMARY_INODE_SIZE;
break;
}
case JFFS2_NODETYPE_DIRENT: {
struct jffs2_sum_dirent_flash *sdrnt_ptr = wpage;
sdrnt_ptr->nodetype = c->summary->sum_list_head->d.nodetype;
sdrnt_ptr->totlen = c->summary->sum_list_head->d.totlen;
sdrnt_ptr->offset = c->summary->sum_list_head->d.offset;
sdrnt_ptr->pino = c->summary->sum_list_head->d.pino;
sdrnt_ptr->version = c->summary->sum_list_head->d.version;
sdrnt_ptr->ino = c->summary->sum_list_head->d.ino;
sdrnt_ptr->nsize = c->summary->sum_list_head->d.nsize;
sdrnt_ptr->type = c->summary->sum_list_head->d.type;
memcpy(sdrnt_ptr->name, c->summary->sum_list_head->d.name,
c->summary->sum_list_head->d.nsize);
wpage += JFFS2_SUMMARY_DIRENT_SIZE(c->summary->sum_list_head->d.nsize);
break;
}
default : {
BUG(); /* unknown node in summary information */
}
}
temp = c->summary->sum_list_head;
c->summary->sum_list_head = c->summary->sum_list_head->u.next;
kfree(temp);
c->summary->sum_num--;
}
jffs2_sum_reset_collected(c->summary);
wpage += padsize;
sm = wpage;
sm->offset = cpu_to_je32(c->sector_size - jeb->free_size);
sm->magic = cpu_to_je32(JFFS2_SUM_MAGIC);
isum.sum_crc = cpu_to_je32(crc32(0, c->summary->sum_buf, datasize));
isum.node_crc = cpu_to_je32(crc32(0, &isum, sizeof(isum) - 8));
vecs[0].iov_base = &isum;
vecs[0].iov_len = sizeof(isum);
vecs[1].iov_base = c->summary->sum_buf;
vecs[1].iov_len = datasize;
dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n",
jeb->offset + c->sector_size - jeb->free_size);
spin_unlock(&c->erase_completion_lock);
ret = jffs2_flash_writev(c, vecs, 2, jeb->offset + c->sector_size -
jeb->free_size, &retlen, 0);
spin_lock(&c->erase_completion_lock);
if (ret || (retlen != infosize)) {
JFFS2_WARNING("Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n",
infosize, jeb->offset + c->sector_size - jeb->free_size, ret, retlen);
//.........这里部分代码省略.........
开发者ID:nighthawk149,项目名称:fvs318g-cfw,代码行数:101,代码来源:summary.c
示例12: jffs2_sum_process_sum_data
//.........这里部分代码省略.........
}
ic = jffs2_scan_make_ino_cache(c, ino);
if (!ic) {
JFFS2_NOTICE("scan_make_ino_cache failed\n");
jffs2_free_raw_node_ref(raw);
kfree(summary);
return -ENOMEM;
}
raw->flash_offset = (jeb->offset + je32_to_cpu(spi->offset)) | REF_UNCHECKED;
raw->__totlen = PAD(je32_to_cpu(spi->totlen));
raw->next_phys = NULL;
raw->next_in_ino = ic->nodes;
ic->nodes = raw;
if (!jeb->first_node)
jeb->first_node = raw;
if (jeb->last_node)
jeb->last_node->next_phys = raw;
jeb->last_node = raw;
*pseudo_random += je32_to_cpu(spi->version);
UNCHECKED_SPACE(PAD(je32_to_cpu(spi->totlen)));
sp += JFFS2_SUMMARY_INODE_SIZE;
break;
}
case JFFS2_NODETYPE_DIRENT: {
struct jffs2_sum_dirent_flash *spd;
spd = sp;
dbg_summary("Dirent at 0x%08x\n",
jeb->offset + je32_to_cpu(spd->offset));
fd = jffs2_alloc_full_dirent(spd->nsize+1);
if (!fd) {
kfree(summary);
return -ENOMEM;
}
memcpy(&fd->name, spd->name, spd->nsize);
fd->name[spd->nsize] = 0;
raw = jffs2_alloc_raw_node_ref();
if (!raw) {
jffs2_free_full_dirent(fd);
JFFS2_NOTICE("allocation of node reference failed\n");
kfree(summary);
return -ENOMEM;
}
ic = jffs2_scan_make_ino_cache(c, je32_to_cpu(spd->pino));
if (!ic) {
jffs2_free_full_dirent(fd);
jffs2_free_raw_node_ref(raw);
kfree(summary);
return -ENOMEM;
}
raw->__totlen = PAD(je32_to_cpu(spd->totlen));
raw->flash_offset = (jeb->offset + je32_to_cpu(spd->offset)) | REF_PRISTINE;
raw->next_phys = NULL;
raw->next_in_ino = ic->nodes;
ic->nodes = raw;
if (!jeb->first_node)
jeb->first_node = raw;
if (jeb->last_node)
jeb->last_node->next_phys = raw;
jeb->last_node = raw;
fd->raw = raw;
fd->next = NULL;
fd->version = je32_to_cpu(spd->version);
fd->ino = je32_to_cpu(spd->ino);
fd->nhash = full_name_hash(fd->name, spd->nsize);
fd->type = spd->type;
USED_SPACE(PAD(je32_to_cpu(spd->totlen)));
jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
*pseudo_random += je32_to_cpu(spd->version);
sp += JFFS2_SUMMARY_DIRENT_SIZE(spd->nsize);
break;
}
default : {
JFFS2_WARNING("Unsupported node type found in summary! Exiting...");
kfree(summary);
return -EIO;
}
}
}
kfree(summary);
return 0;
}
开发者ID:nighthawk149,项目名称:fvs318g-cfw,代码行数:101,代码来源:summary.c
示例13: dump_sum_records
void dump_sum_records()
{
struct jffs2_raw_summary isum;
struct jffs2_sum_marker *sm;
union jffs2_sum_mem *temp;
jint32_t offset;
jint32_t *tpage;
void *wpage;
int datasize, infosize, padsize;
jint32_t magic = cpu_to_je32(JFFS2_SUM_MAGIC);
if (!sum_collected->sum_num || !sum_collected->sum_list_head)
return;
datasize = sum_collected->sum_size + sizeof(struct jffs2_sum_marker);
infosize = sizeof(struct jffs2_raw_summary) + datasize;
padsize = erase_block_size - data_ofs - infosize;
infosize += padsize; datasize += padsize;
offset = cpu_to_je32(data_ofs);
tpage = (jint32_t *) malloc(datasize);
if(!tpage)
error_msg_and_die("Can't allocate memory to dump summary information!\n");
memset(tpage, 0xff, datasize);
memset(&isum, 0, sizeof(isum));
isum.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
isum.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
isum.totlen = cpu_to_je32(infosize);
isum.hdr_crc = cpu_to_je32(crc32(0, &isum, sizeof(struct jffs2_unknown_node) - 4));
isum.padded = cpu_to_je32(0);
if (add_cleanmarkers && found_cleanmarkers) {
isum.cln_mkr = cpu_to_je32(cleanmarker_size);
} else {
isum.cln_mkr = cpu_to_je32(0);
}
isum.sum_num = cpu_to_je32(sum_collected->sum_num);
wpage = tpage;
while (sum_collected->sum_num) {
switch(je16_to_cpu(sum_collected->sum_list_head->u.nodetype)) {
case JFFS2_NODETYPE_INODE : {
struct jffs2_sum_inode_flash *sino_ptr = wpage;
sino_ptr->nodetype = sum_collected->sum_list_head->i.nodetype;
sino_ptr->inode = sum_collected->sum_list_head->i.inode;
sino_ptr->version = sum_collected->sum_list_head->i.version;
sino_ptr->offset = sum_collected->sum_list_head->i.offset;
sino_ptr->totlen = sum_collected->sum_list_head->i.totlen;
wpage += JFFS2_SUMMARY_INODE_SIZE;
break;
}
case JFFS2_NODETYPE_DIRENT : {
struct jffs2_sum_dirent_flash *sdrnt_ptr = wpage;
sdrnt_ptr->nodetype = sum_collected->sum_list_head->d.nodetype;
sdrnt_ptr->totlen = sum_collected->sum_list_head->d.totlen;
sdrnt_ptr->offset = sum_collected->sum_list_head->d.offset;
sdrnt_ptr->pino = sum_collected->sum_list_head->d.pino;
sdrnt_ptr->version = sum_collected->sum_list_head->d.version;
sdrnt_ptr->ino = sum_collected->sum_list_head->d.ino;
sdrnt_ptr->nsize = sum_collected->sum_list_head->d.nsize;
sdrnt_ptr->type = sum_collected->sum_list_head->d.type;
memcpy(sdrnt_ptr->name, sum_collected->sum_list_head->d.name,
sum_collected->sum_list_head->d.nsize);
wpage += JFFS2_SUMMARY_DIRENT_SIZE(sum_collected->sum_list_head->d.nsize);
break;
}
case JFFS2_NODETYPE_XATTR: {
struct jffs2_sum_xattr_flash *sxattr_ptr = wpage;
sxattr_ptr->nodetype = sum_collected->sum_list_head->x.nodetype;
sxattr_ptr->xid = sum_collected->sum_list_head->x.xid;
sxattr_ptr->version = sum_collected->sum_list_head->x.version;
sxattr_ptr->offset = sum_collected->sum_list_head->x.offset;
sxattr_ptr->totlen = sum_collected->sum_list_head->x.totlen;
wpage += JFFS2_SUMMARY_XATTR_SIZE;
break;
}
case JFFS2_NODETYPE_XREF: {
struct jffs2_sum_xref_flash *sxref_ptr = wpage;
sxref_ptr->nodetype = sum_collected->sum_list_head->r.nodetype;
sxref_ptr->offset = sum_collected->sum_list_head->r.offset;
wpage += JFFS2_SUMMARY_XREF_SIZE;
break;
//.........这里部分代码省略.........
开发者ID:DentonGentry,项目名称:gfiber-gfrg100,代码行数:101,代码来源:sumtool.c
注:本文中的JFFS2_SUMMARY_DIRENT_SIZE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论