Lines Matching refs:obj
44 static void yaffs_fix_null_name(struct yaffs_obj *obj, YCHAR *name,
653 void yaffs_set_obj_name(struct yaffs_obj *obj, const YCHAR * name) in yaffs_set_obj_name() argument
655 memset(obj->short_name, 0, sizeof(obj->short_name)); in yaffs_set_obj_name()
658 yaffs_fix_null_name(obj, obj->short_name, in yaffs_set_obj_name()
660 name = obj->short_name; in yaffs_set_obj_name()
664 strcpy(obj->short_name, name); in yaffs_set_obj_name()
667 obj->sum = yaffs_calc_name_sum(name); in yaffs_set_obj_name()
670 void yaffs_set_obj_name_from_oh(struct yaffs_obj *obj, in yaffs_set_obj_name_from_oh() argument
676 yaffs_load_name_from_oh(obj->my_dev, tmp_name, oh->name, in yaffs_set_obj_name_from_oh()
678 yaffs_set_obj_name(obj, tmp_name); in yaffs_set_obj_name_from_oh()
680 yaffs_set_obj_name(obj, oh->name); in yaffs_set_obj_name_from_oh()
1245 static void yaffs_remove_obj_from_dir(struct yaffs_obj *obj) in yaffs_remove_obj_from_dir() argument
1247 struct yaffs_dev *dev = obj->my_dev; in yaffs_remove_obj_from_dir()
1250 yaffs_verify_obj_in_dir(obj); in yaffs_remove_obj_from_dir()
1251 parent = obj->parent; in yaffs_remove_obj_from_dir()
1256 dev->param.remove_obj_fn(obj); in yaffs_remove_obj_from_dir()
1258 list_del_init(&obj->siblings); in yaffs_remove_obj_from_dir()
1259 obj->parent = NULL; in yaffs_remove_obj_from_dir()
1264 void yaffs_add_obj_to_dir(struct yaffs_obj *directory, struct yaffs_obj *obj) in yaffs_add_obj_to_dir() argument
1280 if (obj->siblings.prev == NULL) { in yaffs_add_obj_to_dir()
1287 yaffs_remove_obj_from_dir(obj); in yaffs_add_obj_to_dir()
1290 list_add(&obj->siblings, &directory->variant.dir_variant.children); in yaffs_add_obj_to_dir()
1291 obj->parent = directory; in yaffs_add_obj_to_dir()
1293 if (directory == obj->my_dev->unlinked_dir in yaffs_add_obj_to_dir()
1294 || directory == obj->my_dev->del_dir) { in yaffs_add_obj_to_dir()
1295 obj->unlinked = 1; in yaffs_add_obj_to_dir()
1296 obj->my_dev->n_unlinked_files++; in yaffs_add_obj_to_dir()
1297 obj->rename_allowed = 0; in yaffs_add_obj_to_dir()
1301 yaffs_verify_obj_in_dir(obj); in yaffs_add_obj_to_dir()
1304 static int yaffs_change_obj_name(struct yaffs_obj *obj, in yaffs_change_obj_name() argument
1313 new_dir = obj->parent; /* use the old directory */ in yaffs_change_obj_name()
1322 unlink_op = (new_dir == obj->my_dev->unlinked_dir); in yaffs_change_obj_name()
1323 del_op = (new_dir == obj->my_dev->del_dir); in yaffs_change_obj_name()
1337 yaffs_set_obj_name(obj, new_name); in yaffs_change_obj_name()
1338 obj->dirty = 1; in yaffs_change_obj_name()
1339 yaffs_add_obj_to_dir(new_dir, obj); in yaffs_change_obj_name()
1342 obj->unlinked = 1; in yaffs_change_obj_name()
1345 if (yaffs_update_oh(obj, new_name, 0, del_op, shadows, NULL) >= 0) in yaffs_change_obj_name()
1364 static int yaffs_obj_cache_dirty(struct yaffs_obj *obj) in yaffs_obj_cache_dirty() argument
1366 struct yaffs_dev *dev = obj->my_dev; in yaffs_obj_cache_dirty()
1369 int n_caches = obj->my_dev->param.n_caches; in yaffs_obj_cache_dirty()
1373 if (cache->object == obj && cache->dirty) in yaffs_obj_cache_dirty()
1380 static void yaffs_flush_file_cache(struct yaffs_obj *obj) in yaffs_flush_file_cache() argument
1382 struct yaffs_dev *dev = obj->my_dev; in yaffs_flush_file_cache()
1387 int n_caches = obj->my_dev->param.n_caches; in yaffs_flush_file_cache()
1396 if (dev->cache[i].object == obj && in yaffs_flush_file_cache()
1431 struct yaffs_obj *obj; in yaffs_flush_whole_cache() local
1439 obj = NULL; in yaffs_flush_whole_cache()
1440 for (i = 0; i < n_caches && !obj; i++) { in yaffs_flush_whole_cache()
1442 obj = dev->cache[i].object; in yaffs_flush_whole_cache()
1444 if (obj) in yaffs_flush_whole_cache()
1445 yaffs_flush_file_cache(obj); in yaffs_flush_whole_cache()
1446 } while (obj); in yaffs_flush_whole_cache()
1519 static struct yaffs_cache *yaffs_find_chunk_cache(const struct yaffs_obj *obj, in yaffs_find_chunk_cache() argument
1522 struct yaffs_dev *dev = obj->my_dev; in yaffs_find_chunk_cache()
1529 if (dev->cache[i].object == obj && in yaffs_find_chunk_cache()
1596 static void yaffs_unhash_obj(struct yaffs_obj *obj) in yaffs_unhash_obj() argument
1599 struct yaffs_dev *dev = obj->my_dev; in yaffs_unhash_obj()
1602 if (!list_empty(&obj->hash_link)) { in yaffs_unhash_obj()
1603 list_del_init(&obj->hash_link); in yaffs_unhash_obj()
1604 bucket = yaffs_hash_fn(obj->obj_id); in yaffs_unhash_obj()
1610 static void yaffs_free_obj(struct yaffs_obj *obj) in yaffs_free_obj() argument
1614 if (!obj) { in yaffs_free_obj()
1618 dev = obj->my_dev; in yaffs_free_obj()
1620 obj, obj->my_inode); in yaffs_free_obj()
1621 if (obj->parent) in yaffs_free_obj()
1623 if (!list_empty(&obj->siblings)) in yaffs_free_obj()
1626 if (obj->my_inode) { in yaffs_free_obj()
1630 obj->defered_free = 1; in yaffs_free_obj()
1634 yaffs_unhash_obj(obj); in yaffs_free_obj()
1636 yaffs_free_raw_obj(dev, obj); in yaffs_free_obj()
1641 void yaffs_handle_defered_free(struct yaffs_obj *obj) in yaffs_handle_defered_free() argument
1643 if (obj->defered_free) in yaffs_handle_defered_free()
1644 yaffs_free_obj(obj); in yaffs_handle_defered_free()
1667 static void yaffs_soft_del_file(struct yaffs_obj *obj) in yaffs_soft_del_file() argument
1669 if (!obj->deleted || in yaffs_soft_del_file()
1670 obj->variant_type != YAFFS_OBJECT_TYPE_FILE || in yaffs_soft_del_file()
1671 obj->soft_del) in yaffs_soft_del_file()
1674 if (obj->n_data_chunks <= 0) { in yaffs_soft_del_file()
1677 yaffs_free_tnode(obj->my_dev, obj->variant.file_variant.top); in yaffs_soft_del_file()
1678 obj->variant.file_variant.top = NULL; in yaffs_soft_del_file()
1681 obj->obj_id); in yaffs_soft_del_file()
1682 yaffs_generic_obj_del(obj); in yaffs_soft_del_file()
1684 yaffs_soft_del_worker(obj, in yaffs_soft_del_file()
1685 obj->variant.file_variant.top, in yaffs_soft_del_file()
1686 obj->variant. in yaffs_soft_del_file()
1688 obj->soft_del = 1; in yaffs_soft_del_file()
1797 struct yaffs_obj *obj = yaffs_alloc_raw_obj(dev); in yaffs_alloc_empty_obj() local
1799 if (!obj) in yaffs_alloc_empty_obj()
1800 return obj; in yaffs_alloc_empty_obj()
1806 memset(obj, 0, sizeof(struct yaffs_obj)); in yaffs_alloc_empty_obj()
1807 obj->being_created = 1; in yaffs_alloc_empty_obj()
1809 obj->my_dev = dev; in yaffs_alloc_empty_obj()
1810 obj->hdr_chunk = 0; in yaffs_alloc_empty_obj()
1811 obj->variant_type = YAFFS_OBJECT_TYPE_UNKNOWN; in yaffs_alloc_empty_obj()
1812 INIT_LIST_HEAD(&(obj->hard_links)); in yaffs_alloc_empty_obj()
1813 INIT_LIST_HEAD(&(obj->hash_link)); in yaffs_alloc_empty_obj()
1814 INIT_LIST_HEAD(&obj->siblings); in yaffs_alloc_empty_obj()
1818 obj->parent = dev->root_dir; in yaffs_alloc_empty_obj()
1819 list_add(&(obj->siblings), in yaffs_alloc_empty_obj()
1828 yaffs_add_obj_to_dir(dev->lost_n_found, obj); in yaffs_alloc_empty_obj()
1830 obj->being_created = 0; in yaffs_alloc_empty_obj()
1834 return obj; in yaffs_alloc_empty_obj()
1974 struct yaffs_obj *obj = in yaffs_create_fake_dir() local
1977 if (!obj) in yaffs_create_fake_dir()
1980 obj->fake = 1; /* it is fake so it might not use NAND */ in yaffs_create_fake_dir()
1981 obj->rename_allowed = 0; in yaffs_create_fake_dir()
1982 obj->unlink_allowed = 0; in yaffs_create_fake_dir()
1983 obj->deleted = 0; in yaffs_create_fake_dir()
1984 obj->unlinked = 0; in yaffs_create_fake_dir()
1985 obj->yst_mode = mode; in yaffs_create_fake_dir()
1986 obj->my_dev = dev; in yaffs_create_fake_dir()
1987 obj->hdr_chunk = 0; /* Not a valid chunk. */ in yaffs_create_fake_dir()
1988 return obj; in yaffs_create_fake_dir()
2056 static void yaffs_update_parent(struct yaffs_obj *obj) in yaffs_update_parent() argument
2060 if (!obj) in yaffs_update_parent()
2062 dev = obj->my_dev; in yaffs_update_parent()
2063 obj->dirty = 1; in yaffs_update_parent()
2064 yaffs_load_current_time(obj, 0, 1); in yaffs_update_parent()
2066 struct list_head *link = &obj->variant.dir_variant.dirty; in yaffs_update_parent()
2072 obj->obj_id); in yaffs_update_parent()
2076 yaffs_update_oh(obj, NULL, 0, 0, 0, NULL); in yaffs_update_parent()
2083 struct yaffs_obj *obj; in yaffs_update_dirty_dirs() local
2095 obj = list_entry(o_v, struct yaffs_obj, variant); in yaffs_update_dirty_dirs()
2098 obj->obj_id); in yaffs_update_dirty_dirs()
2100 if (obj->dirty) in yaffs_update_dirty_dirs()
2101 yaffs_update_oh(obj, NULL, 0, 0, 0, NULL); in yaffs_update_dirty_dirs()
3042 static int yaffs_do_xattrib_mod(struct yaffs_obj *obj, int set, in yaffs_do_xattrib_mod() argument
3056 result = yaffs_update_oh(obj, NULL, 0, 0, 0, &xmod); in yaffs_do_xattrib_mod()
3064 static int yaffs_apply_xattrib_mod(struct yaffs_obj *obj, char *buffer, in yaffs_apply_xattrib_mod() argument
3069 struct yaffs_dev *dev = obj->my_dev; in yaffs_apply_xattrib_mod()
3080 obj->has_xattr = nval_hasvalues(x_buffer, x_size); in yaffs_apply_xattrib_mod()
3081 obj->xattr_known = 1; in yaffs_apply_xattrib_mod()
3087 static int yaffs_do_xattrib_fetch(struct yaffs_obj *obj, const YCHAR *name, in yaffs_do_xattrib_fetch() argument
3093 struct yaffs_dev *dev = obj->my_dev; in yaffs_do_xattrib_fetch()
3099 if (obj->hdr_chunk < 1) in yaffs_do_xattrib_fetch()
3105 if (obj->xattr_known && !obj->has_xattr) { in yaffs_do_xattrib_fetch()
3117 yaffs_rd_chunk_tags_nand(dev, obj->hdr_chunk, (u8 *) buffer, &tags); in yaffs_do_xattrib_fetch()
3124 if (!obj->xattr_known) { in yaffs_do_xattrib_fetch()
3125 obj->has_xattr = nval_hasvalues(x_buffer, x_size); in yaffs_do_xattrib_fetch()
3126 obj->xattr_known = 1; in yaffs_do_xattrib_fetch()
3138 int yaffs_set_xattrib(struct yaffs_obj *obj, const YCHAR * name, in yaffs_set_xattrib() argument
3141 return yaffs_do_xattrib_mod(obj, 1, name, value, size, flags); in yaffs_set_xattrib()
3144 int yaffs_remove_xattrib(struct yaffs_obj *obj, const YCHAR * name) in yaffs_remove_xattrib() argument
3146 return yaffs_do_xattrib_mod(obj, 0, name, NULL, 0, 0); in yaffs_remove_xattrib()
3149 int yaffs_get_xattrib(struct yaffs_obj *obj, const YCHAR * name, void *value, in yaffs_get_xattrib() argument
3152 return yaffs_do_xattrib_fetch(obj, name, value, size); in yaffs_get_xattrib()
3155 int yaffs_list_xattrib(struct yaffs_obj *obj, char *buffer, int size) in yaffs_list_xattrib() argument
3157 return yaffs_do_xattrib_fetch(obj, NULL, buffer, size); in yaffs_list_xattrib()
3733 void yaffs_resize_file_down(struct yaffs_obj *obj, loff_t new_size) argument
3737 struct yaffs_dev *dev = obj->my_dev;
3741 yaffs_prune_chunks(obj, new_size);
3748 yaffs_rd_data_obj(obj, last_chunk, local_buffer);
3752 yaffs_wr_data_obj(obj, last_chunk, local_buffer,
3758 obj->variant.file_variant.file_size = new_size;
3760 yaffs_prune_tree(dev, &obj->variant.file_variant);
3887 int yaffs_is_non_empty_dir(struct yaffs_obj *obj) argument
3889 return (obj &&
3890 obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY) &&
3891 !(list_empty(&obj->variant.dir_variant.children));
3894 static int yaffs_del_dir(struct yaffs_obj *obj) argument
3897 if (yaffs_is_non_empty_dir(obj))
3900 return yaffs_generic_obj_del(obj);
3920 int yaffs_del_obj(struct yaffs_obj *obj) argument
3924 switch (obj->variant_type) {
3926 ret_val = yaffs_del_file(obj);
3929 if (!list_empty(&obj->variant.dir_variant.dirty)) {
3932 obj->obj_id);
3933 list_del_init(&obj->variant.dir_variant.dirty);
3935 return yaffs_del_dir(obj);
3938 ret_val = yaffs_del_symlink(obj);
3941 ret_val = yaffs_del_link(obj);
3944 ret_val = yaffs_generic_obj_del(obj);
3953 static int yaffs_unlink_worker(struct yaffs_obj *obj) argument
3957 if (!obj)
3960 if (!obj->my_inode)
3963 yaffs_update_parent(obj->parent);
3965 if (obj->variant_type == YAFFS_OBJECT_TYPE_HARDLINK) {
3966 return yaffs_del_link(obj);
3967 } else if (!list_empty(&obj->hard_links)) {
3987 hl = list_entry(obj->hard_links.next, struct yaffs_obj,
3995 yaffs_add_obj_to_dir(obj->my_dev->unlinked_dir, hl);
3997 ret_val = yaffs_change_obj_name(obj, parent, name, 0, 0);
4005 switch (obj->variant_type) {
4007 return yaffs_del_file(obj);
4010 list_del_init(&obj->variant.dir_variant.dirty);
4011 return yaffs_del_dir(obj);
4014 return yaffs_del_symlink(obj);
4017 return yaffs_generic_obj_del(obj);
4024 } else if (yaffs_is_non_empty_dir(obj)) {
4027 return yaffs_change_obj_name(obj, obj->my_dev->unlinked_dir,
4032 static int yaffs_unlink_obj(struct yaffs_obj *obj) argument
4034 if (obj && obj->unlink_allowed)
4035 return yaffs_unlink_worker(obj);
4042 struct yaffs_obj *obj; local
4044 obj = yaffs_find_by_name(dir, name);
4045 return yaffs_unlink_obj(obj);
4054 struct yaffs_obj *obj = NULL; local
4088 obj = yaffs_find_by_name(old_dir, old_name);
4090 obj = old_dir;
4091 old_dir = obj->parent;
4094 if (obj && obj->rename_allowed) {
4099 } else if (existing_target && existing_target != obj) {
4108 yaffs_change_obj_name(obj, new_dir, new_name, force,
4115 result = yaffs_change_obj_name(obj, new_dir, new_name, 1, 0);
4131 struct yaffs_obj *obj; local
4137 obj = yaffs_find_by_number(dev, obj_id);
4138 if (obj)
4146 obj =
4148 if (!obj)
4150 obj->is_shadowed = 1;
4151 yaffs_add_obj_to_dir(dev->unlinked_dir, obj);
4152 obj->variant.file_variant.shrink_size = 0;
4153 obj->valid = 1; /* So that we don't read any other info. */
4225 static int yaffs_has_null_parent(struct yaffs_dev *dev, struct yaffs_obj *obj) argument
4227 return (obj == dev->del_dir ||
4228 obj == dev->unlinked_dir || obj == dev->root_dir);
4233 struct yaffs_obj *obj; local
4251 obj = list_entry(lh, struct yaffs_obj, hash_link);
4252 parent = obj->parent;
4254 if (yaffs_has_null_parent(dev, obj)) {
4285 obj->obj_id);
4286 yaffs_add_obj_to_dir(dev->lost_n_found, obj);
4297 struct yaffs_obj *obj; local
4305 obj = list_entry(lh, struct yaffs_obj, siblings);
4306 if (obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY)
4307 yaffs_del_dir_contents(obj);
4310 obj->obj_id);
4311 yaffs_unlink_obj(obj);
4377 struct yaffs_obj *yaffs_get_equivalent_obj(struct yaffs_obj *obj) argument
4379 if (obj && obj->variant_type == YAFFS_OBJECT_TYPE_HARDLINK) {
4380 obj = obj->variant.hardlink_variant.equiv_obj;
4381 yaffs_check_obj_details_loaded(obj);
4383 return obj;
4405 static void yaffs_fix_null_name(struct yaffs_obj *obj, YCHAR *name, argument
4413 unsigned v = obj->obj_id;
4427 int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size) argument
4430 yaffs_check_obj_details_loaded(obj);
4431 if (obj->obj_id == YAFFS_OBJECTID_LOSTNFOUND) {
4433 } else if (obj->short_name[0]) {
4434 strcpy(name, obj->short_name);
4435 } else if (obj->hdr_chunk > 0) {
4437 u8 *buffer = yaffs_get_temp_buffer(obj->my_dev);
4441 memset(buffer, 0, obj->my_dev->data_bytes_per_chunk);
4443 if (obj->hdr_chunk > 0) {
4444 result = yaffs_rd_chunk_tags_nand(obj->my_dev,
4445 obj->hdr_chunk,
4448 yaffs_load_name_from_oh(obj->my_dev, name, oh->name,
4451 yaffs_release_temp_buffer(obj->my_dev, buffer);
4454 yaffs_fix_null_name(obj, name, buffer_size);
4459 loff_t yaffs_get_obj_length(struct yaffs_obj *obj) argument
4462 obj = yaffs_get_equivalent_obj(obj);
4464 if (obj->variant_type == YAFFS_OBJECT_TYPE_FILE)
4465 return obj->variant.file_variant.file_size;
4466 if (obj->variant_type == YAFFS_OBJECT_TYPE_SYMLINK) {
4467 if (!obj->variant.symlink_variant.alias)
4469 return strnlen(obj->variant.symlink_variant.alias,
4473 return obj->my_dev->data_bytes_per_chunk;
4477 int yaffs_get_obj_link_count(struct yaffs_obj *obj) argument
4482 if (!obj->unlinked)
4485 list_for_each(i, &obj->hard_links)
4491 int yaffs_get_obj_inode(struct yaffs_obj *obj) argument
4493 obj = yaffs_get_equivalent_obj(obj);
4495 return obj->obj_id;
4498 unsigned yaffs_get_obj_type(struct yaffs_obj *obj) argument
4500 obj = yaffs_get_equivalent_obj(obj);
4502 switch (obj->variant_type) {
4516 if (S_ISFIFO(obj->yst_mode))
4518 if (S_ISCHR(obj->yst_mode))
4520 if (S_ISBLK(obj->yst_mode))
4522 if (S_ISSOCK(obj->yst_mode))
4532 YCHAR *yaffs_get_symlink_alias(struct yaffs_obj *obj) argument
4534 obj = yaffs_get_equivalent_obj(obj);
4535 if (obj->variant_type == YAFFS_OBJECT_TYPE_SYMLINK)
4536 return yaffs_clone_str(obj->variant.symlink_variant.alias);