yaffs_trace(YAFFS_TRACE_ERROR,
"yaffs tragedy:attempt to put data chunk into a non-file"
);
- YBUG();
+ BUG();
}
yaffs_chunk_del(dev, nand_chunk, 1, __LINE__);
yaffs_trace(YAFFS_TRACE_ALWAYS,
"tragedy: Trying to add an object to a null pointer directory"
);
- YBUG();
+ BUG();
return;
}
if (directory->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) {
yaffs_trace(YAFFS_TRACE_ALWAYS,
"tragedy: Trying to add an object to a non-directory"
);
- YBUG();
+ BUG();
}
if (obj->siblings.prev == NULL) {
/* Not initialised */
- YBUG();
+ BUG();
}
yaffs_verify_dir(directory);
yaffs_trace(YAFFS_TRACE_ALWAYS,
"tragedy: yaffs_change_obj_name: new_dir is not a directory"
);
- YBUG();
+ BUG();
}
/* TODO: Do we need this different handling for YAFFS2 and YAFFS1?? */
/* FreeObject frees up a Object and puts it back on the free list */
static void yaffs_free_obj(struct yaffs_obj *obj)
{
- struct yaffs_dev *dev = obj->my_dev;
+ struct yaffs_dev *dev;
+ if (!obj) {
+ BUG();
+ return;
+ }
+ dev = obj->my_dev;
yaffs_trace(YAFFS_TRACE_OS, "FreeObject %p inode %p",
obj, obj->my_inode);
-
- if (!obj)
- YBUG();
if (obj->parent)
- YBUG();
+ BUG();
if (!list_empty(&obj->siblings))
- YBUG();
+ BUG();
if (obj->my_inode) {
/* We're still hooked up to a cached inode.
yaffs_trace(YAFFS_TRACE_ERROR,
"Writing %d bytes to chunk!!!!!!!!!",
n_bytes);
- YBUG();
+ BUG();
}
new_chunk_id =
if (n_writeback < 0 ||
n_writeback > dev->data_bytes_per_chunk)
- YBUG();
+ BUG();
} else {
n_copy = dev->data_bytes_per_chunk - start;
int result;
struct yaffs_dev *dev;
- if (!old_dir || old_dir->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY)
- YBUG();
- if (!new_dir || new_dir->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY)
- YBUG();
+ if (!old_dir || old_dir->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) {
+ BUG();
+ return YAFFS_FAIL;
+ }
+ if (!new_dir || new_dir->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) {
+ BUG();
+ return YAFFS_FAIL;
+ }
dev = old_dir->my_dev;
/* Soft delete all the unlinked files */
list_for_each_safe(i, n,
&dev->unlinked_dir->variant.dir_variant.children) {
- if (i) {
- l = list_entry(i, struct yaffs_obj, siblings);
- yaffs_del_obj(l);
- }
+ l = list_entry(i, struct yaffs_obj, siblings);
+ yaffs_del_obj(l);
}
list_for_each_safe(i, n, &dev->del_dir->variant.dir_variant.children) {
- if (i) {
- l = list_entry(i, struct yaffs_obj, siblings);
- yaffs_del_obj(l);
- }
+ l = list_entry(i, struct yaffs_obj, siblings);
+ yaffs_del_obj(l);
}
}
for (i = 0; i < YAFFS_NOBJECT_BUCKETS; i++) {
list_for_each_safe(lh, n, &dev->obj_bucket[i].list) {
- if (lh) {
- obj =
- list_entry(lh, struct yaffs_obj, hash_link);
- parent = obj->parent;
-
- if (yaffs_has_null_parent(dev, obj)) {
- /* These directories are not hanging */
- hanging = 0;
- } else if (!parent
- || parent->variant_type !=
- YAFFS_OBJECT_TYPE_DIRECTORY) {
- hanging = 1;
- } else if (yaffs_has_null_parent(dev, parent)) {
- hanging = 0;
- } else {
- /*
- * Need to follow the parent chain to
- * see if it is hanging.
- */
- hanging = 0;
- depth_limit = 100;
-
- while (parent != dev->root_dir &&
- parent->parent &&
- parent->parent->variant_type ==
- YAFFS_OBJECT_TYPE_DIRECTORY &&
- depth_limit > 0) {
- parent = parent->parent;
- depth_limit--;
- }
- if (parent != dev->root_dir)
- hanging = 1;
- }
- if (hanging) {
- yaffs_trace(YAFFS_TRACE_SCAN,
- "Hanging object %d moved to lost and found",
- obj->obj_id);
- yaffs_add_obj_to_dir(dev->lost_n_found,
- obj);
+ obj = list_entry(lh, struct yaffs_obj, hash_link);
+ parent = obj->parent;
+
+ if (yaffs_has_null_parent(dev, obj)) {
+ /* These directories are not hanging */
+ hanging = 0;
+ } else if (!parent ||
+ parent->variant_type !=
+ YAFFS_OBJECT_TYPE_DIRECTORY) {
+ hanging = 1;
+ } else if (yaffs_has_null_parent(dev, parent)) {
+ hanging = 0;
+ } else {
+ /*
+ * Need to follow the parent chain to
+ * see if it is hanging.
+ */
+ hanging = 0;
+ depth_limit = 100;
+
+ while (parent != dev->root_dir &&
+ parent->parent &&
+ parent->parent->variant_type ==
+ YAFFS_OBJECT_TYPE_DIRECTORY &&
+ depth_limit > 0) {
+ parent = parent->parent;
+ depth_limit--;
}
+ if (parent != dev->root_dir)
+ hanging = 1;
+ }
+ if (hanging) {
+ yaffs_trace(YAFFS_TRACE_SCAN,
+ "Hanging object %d moved to lost and found",
+ obj->obj_id);
+ yaffs_add_obj_to_dir(dev->lost_n_found, obj);
}
}
}
struct list_head *n;
if (dir->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY)
- YBUG();
+ BUG();
list_for_each_safe(lh, n, &dir->variant.dir_variant.children) {
- if (lh) {
- obj = list_entry(lh, struct yaffs_obj, siblings);
- if (obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY)
- yaffs_del_dir_contents(obj);
- yaffs_trace(YAFFS_TRACE_SCAN,
- "Deleting lost_found object %d",
- obj->obj_id);
- yaffs_unlink_obj(obj);
- }
+ obj = list_entry(lh, struct yaffs_obj, siblings);
+ if (obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY)
+ yaffs_del_dir_contents(obj);
+ yaffs_trace(YAFFS_TRACE_SCAN,
+ "Deleting lost_found object %d",
+ obj->obj_id);
+ yaffs_unlink_obj(obj);
}
}
yaffs_trace(YAFFS_TRACE_ALWAYS,
"tragedy: yaffs_find_by_name: null pointer directory"
);
- YBUG();
+ BUG();
return NULL;
}
if (directory->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) {
yaffs_trace(YAFFS_TRACE_ALWAYS,
"tragedy: yaffs_find_by_name: non-directory"
);
- YBUG();
+ BUG();
}
sum = yaffs_calc_name_sum(name);
l = list_entry(i, struct yaffs_obj, siblings);
if (l->parent != directory)
- YBUG();
+ BUG();
yaffs_check_obj_details_loaded(l);
return DT_BLK;
if (S_ISSOCK(obj->yst_mode))
return DT_SOCK;
+ return DT_REG;
+ break;
default:
return DT_REG;
break;