Lines Matching defs:in

41 static int yaffs_wr_data_obj(struct yaffs_obj *in, int inode_chunk,
101 /* Function to return the number of shifts to get a 1 in bit 0
268 * Note that root might have a presence in NAND if permissions are set.
510 * Check the first page we try to write in a block.
675 /* Figure out if the name will fit in ascii character set */
768 * in the tnode.
864 * in the tree. 0 means only the level 0 tnode is in the tree.
913 * This happens in two steps:
996 /* Don't have one, none passed in */
1055 int yaffs_find_chunk_in_file(struct yaffs_obj *in, int inode_chunk,
1063 struct yaffs_dev *dev = in->my_dev;
1070 tn = yaffs_find_tnode_0(dev, &in->variant.file_variant, inode_chunk);
1077 ret_val = yaffs_find_chunk_in_group(dev, the_chunk, tags, in->obj_id,
1082 static int yaffs_find_del_file_chunk(struct yaffs_obj *in, int inode_chunk,
1089 struct yaffs_dev *dev = in->my_dev;
1097 tn = yaffs_find_tnode_0(dev, &in->variant.file_variant, inode_chunk);
1104 ret_val = yaffs_find_chunk_in_group(dev, the_chunk, tags, in->obj_id,
1107 /* Delete the entry in the filestructure (if found) */
1114 int yaffs_put_chunk_in_file(struct yaffs_obj *in, int inode_chunk,
1125 struct yaffs_dev *dev = in->my_dev;
1131 if (in->variant_type != YAFFS_OBJECT_TYPE_FILE) {
1148 &in->variant.file_variant,
1194 yaffs_find_chunk_in_file(in, inode_chunk,
1202 "yaffs tragedy: existing chunk < 0 in scan"
1240 in->n_data_chunks++;
1264 * the chunks in the file.
1271 static int yaffs_soft_del_worker(struct yaffs_obj *in, struct yaffs_tnode *tn,
1277 struct yaffs_dev *dev = in->my_dev;
1288 yaffs_soft_del_worker(in,
1400 * then it is OK to just stuff it in since duplicate names are OK.
1500 /* Find a dirty object in the cache and flush it...
1551 * Thery were all in use.
1641 static void yaffs_invalidate_whole_cache(struct yaffs_obj *in)
1644 struct yaffs_dev *dev = in->my_dev;
1649 if (dev->cache[i].object == in)
1706 static int yaffs_generic_obj_del(struct yaffs_obj *in)
1708 /* Iinvalidate the file's data in the cache, without flushing. */
1709 yaffs_invalidate_whole_cache(in);
1711 if (in->my_dev->param.is_yaffs2 && in->parent != in->my_dev->del_dir) {
1713 yaffs_change_obj_name(in, in->my_dev->del_dir, _Y("deleted"), 0,
1717 yaffs_remove_obj_from_dir(in);
1718 yaffs_chunk_del(in->my_dev, in->hdr_chunk, 1, __LINE__);
1719 in->hdr_chunk = 0;
1721 yaffs_free_obj(in);
1763 * If there is no data in a subtree then it is pruned.
1826 * We can do this if only the 0th element in the tnode is in use
1883 * NB Can't put root or lost-n-found in lost-n-found so
1942 static void yaffs_hash_obj(struct yaffs_obj *in)
1944 int bucket = yaffs_hash_fn(in->obj_id);
1945 struct yaffs_dev *dev = in->my_dev;
1947 list_add(&in->hash_link, &dev->obj_bucket[bucket].list);
1955 struct yaffs_obj *in;
1958 /* Look if it is in the list */
1959 in = list_entry(i, struct yaffs_obj, hash_link);
1960 if (in->obj_id == number) {
1962 if (in->defered_free)
1964 return in;
2098 * link (ie. name) is created or deleted in the directory.
2106 * of updates when many files in a directory are changed within a brief period.
2177 struct yaffs_obj *in;
2192 in = yaffs_new_obj(dev, -1, type);
2194 if (!in) {
2199 in->hdr_chunk = 0;
2200 in->valid = 1;
2201 in->variant_type = type;
2203 in->yst_mode = mode;
2205 yaffs_attribs_init(in, gid, uid, rdev);
2207 in->n_data_chunks = 0;
2209 yaffs_set_obj_name(in, name);
2210 in->dirty = 1;
2212 yaffs_add_obj_to_dir(parent, in);
2214 in->my_dev = parent->my_dev;
2218 in->variant.symlink_variant.alias = str;
2221 in->variant.hardlink_variant.equiv_obj = equiv_obj;
2222 in->variant.hardlink_variant.equiv_id = equiv_obj->obj_id;
2223 list_add(&in->hard_links, &equiv_obj->hard_links);
2233 if (yaffs_update_oh(in, name, 0, 0, 0, NULL) < 0) {
2235 yaffs_del_obj(in);
2236 in = NULL;
2239 if (in)
2242 return in;
2280 /* Get the real object in case we were fed a hard link obj */
2458 "Collecting chunk in block %d, %d %d %d ",
2477 "gc: page in gc mismatch: %d %d %d %d",
2486 "page %d in gc has no object: %d %d %d ",
2495 /* Data chunk in a soft deleted file,
2520 /* It's either a data chunk in a live
2522 * interested in it.
2599 "Collecting block %d, in use %d, shrink %d, whole_block %d",
2616 "Collecting block %d that has no chunks in use",
2635 /* Page is in use and might need to be copied */
2737 * block has only a few pages in use.
2852 * The idea is to help clear out space in a more spread-out manner.
2964 static int yaffs_rd_data_obj(struct yaffs_obj *in, int inode_chunk, u8 * buffer)
2966 int nand_chunk = yaffs_find_chunk_in_file(in, inode_chunk, NULL);
2969 return yaffs_rd_chunk_tags_nand(in->my_dev, nand_chunk,
2976 memset(buffer, 0, in->my_dev->data_bytes_per_chunk);
3040 static int yaffs_wr_data_obj(struct yaffs_obj *in, int inode_chunk,
3052 struct yaffs_dev *dev = in->my_dev;
3056 /* Get the previous chunk at this location in the file if it exists.
3060 prev_chunk_id = yaffs_find_chunk_in_file(in, inode_chunk, &prev_tags);
3062 !yaffs_put_chunk_in_file(in, inode_chunk, 0, 0))
3069 new_tags.obj_id = in->obj_id;
3085 yaffs_put_chunk_in_file(in, inode_chunk, new_chunk_id, 0);
3090 yaffs_verify_file_sane(in);
3216 static void yaffs_check_obj_details_loaded(struct yaffs_obj *in)
3225 if (!in || !in->lazy_loaded || in->hdr_chunk < 1)
3228 dev = in->my_dev;
3229 in->lazy_loaded = 0;
3232 result = yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags);
3235 in->yst_mode = oh->yst_mode;
3236 yaffs_load_attribs(in, oh);
3237 yaffs_set_obj_name_from_oh(in, oh);
3239 if (in->variant_type == YAFFS_OBJECT_TYPE_SYMLINK) {
3240 in->variant.symlink_variant.alias =
3242 if (!in->variant.symlink_variant.alias)
3251 int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force,
3256 struct yaffs_dev *dev = in->my_dev;
3271 if (in->fake && in != dev->root_dir && !force && !xmod)
3275 yaffs_check_obj_details_loaded(in);
3277 buffer = yaffs_get_temp_buffer(in->my_dev);
3280 prev_chunk_id = in->hdr_chunk;
3286 yaffs_verify_oh(in, oh, &old_tags, 0);
3293 oh->type = in->variant_type;
3294 oh->yst_mode = in->yst_mode;
3297 yaffs_load_attribs_oh(oh, in);
3299 if (in->parent)
3300 oh->parent_obj_id = in->parent->obj_id;
3315 switch (in->variant_type) {
3322 file_size = in->variant.file_variant.file_size;
3326 oh->equiv_id = in->variant.hardlink_variant.equiv_id;
3335 alias = in->variant.symlink_variant.alias;
3345 yaffs_apply_xattrib_mod(in, (char *)buffer, xmod);
3349 in->serial++;
3351 new_tags.obj_id = in->obj_id;
3352 new_tags.serial_number = in->serial;
3361 new_tags.extra_obj_type = in->variant_type;
3362 yaffs_verify_oh(in, oh, &new_tags, 1);
3364 /* Create new chunk in NAND */
3375 in->hdr_chunk = new_chunk_id;
3380 if (!yaffs_obj_cache_dirty(in))
3381 in->dirty = 0;
3386 bi = yaffs_get_block_info(in->my_dev,
3388 in->my_dev->param.chunks_per_block);
3406 int yaffs_file_rd(struct yaffs_obj *in, u8 * buffer, loff_t offset, int n_bytes)
3416 dev = in->my_dev;
3422 /* OK now check for the curveball where the start and end are in
3430 cache = yaffs_find_chunk_cache(in, chunk);
3432 /* If the chunk is already in the cache or it is less than
3440 /* If we can't find the data in the cache,
3445 yaffs_grab_chunk_cache(in->my_dev);
3446 cache->object = in;
3450 yaffs_rd_data_obj(in, chunk,
3467 yaffs_rd_data_obj(in, chunk, local_buffer);
3475 yaffs_rd_data_obj(in, chunk, buffer);
3485 int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset,
3501 dev = in->my_dev;
3513 chunk++; /* File pos to chunk in file offset */
3515 /* OK now check for the curveball where the start and end are in
3531 if (chunk_start > in->variant.file_variant.file_size)
3535 in->variant.file_variant.file_size -
3565 /* If we can't find the data in the cache, then
3567 cache = yaffs_find_chunk_cache(in, chunk);
3572 cache->object = in;
3576 yaffs_rd_data_obj(in, chunk,
3619 yaffs_rd_data_obj(in, chunk, local_buffer);
3623 yaffs_wr_data_obj(in, chunk,
3633 yaffs_wr_data_obj(in, chunk, buffer,
3638 yaffs_invalidate_chunk_cache(in, chunk);
3651 if ((start_write + n_done) > in->variant.file_variant.file_size)
3652 in->variant.file_variant.file_size = (start_write + n_done);
3654 in->dirty = 1;
3658 int yaffs_wr_file(struct yaffs_obj *in, const u8 *buffer, loff_t offset,
3661 yaffs2_handle_hole(in, offset);
3662 return yaffs_do_file_wr(in, buffer, offset, n_bytes, write_through);
3667 static void yaffs_prune_chunks(struct yaffs_obj *in, loff_t new_size)
3670 struct yaffs_dev *dev = in->my_dev;
3671 loff_t old_size = in->variant.file_variant.file_size;
3697 chunk_id = yaffs_find_del_file_chunk(in, i, NULL);
3711 in->n_data_chunks--;
3747 int yaffs_resize_file(struct yaffs_obj *in, loff_t new_size)
3749 struct yaffs_dev *dev = in->my_dev;
3750 loff_t old_size = in->variant.file_variant.file_size;
3752 yaffs_flush_file_cache(in, 1);
3753 yaffs_invalidate_whole_cache(in);
3757 if (in->variant_type != YAFFS_OBJECT_TYPE_FILE)
3764 yaffs2_handle_hole(in, new_size);
3765 in->variant.file_variant.file_size = new_size;
3768 yaffs_resize_file_down(in, new_size);
3773 * Do this only if the file is not in the deleted directories
3776 if (in->parent &&
3777 !in->is_shadowed &&
3778 in->parent->obj_id != YAFFS_OBJECTID_UNLINKED &&
3779 in->parent->obj_id != YAFFS_OBJECTID_DELETED)
3780 yaffs_update_oh(in, NULL, 0, 0, 0, NULL);
3785 int yaffs_flush_file(struct yaffs_obj *in,
3790 if (!in->dirty)
3793 yaffs_flush_file_cache(in, discard_cache);
3799 yaffs_load_current_time(in, 0, 0);
3801 return (yaffs_update_oh(in, NULL, 0, 0, 0, NULL) >= 0) ?
3810 static int yaffs_unlink_file_if_needed(struct yaffs_obj *in)
3814 struct yaffs_dev *dev = in->my_dev;
3816 if (!in->my_inode)
3821 yaffs_change_obj_name(in, in->my_dev->del_dir,
3825 in->obj_id);
3826 in->deleted = 1;
3827 in->my_dev->n_deleted_files++;
3829 yaffs_resize_file(in, 0);
3830 yaffs_soft_del_file(in);
3833 yaffs_change_obj_name(in, in->my_dev->unlinked_dir,
3839 static int yaffs_del_file(struct yaffs_obj *in)
3842 int deleted; /* Need to cache value on stack if in is freed */
3843 struct yaffs_dev *dev = in->my_dev;
3846 yaffs_resize_file(in, 0);
3848 if (in->n_data_chunks > 0) {
3849 /* Use soft deletion if there is data in the file.
3852 if (!in->unlinked)
3853 ret_val = yaffs_unlink_file_if_needed(in);
3855 deleted = in->deleted;
3857 if (ret_val == YAFFS_OK && in->unlinked && !in->deleted) {
3858 in->deleted = 1;
3860 in->my_dev->n_deleted_files++;
3861 yaffs_soft_del_file(in);
3866 yaffs_free_tnode(in->my_dev, in->variant.file_variant.top);
3867 in->variant.file_variant.top = NULL;
3868 yaffs_generic_obj_del(in);
3890 static int yaffs_del_symlink(struct yaffs_obj *in)
3892 kfree(in->variant.symlink_variant.alias);
3893 in->variant.symlink_variant.alias = NULL;
3895 return yaffs_generic_obj_del(in);
3898 static int yaffs_del_link(struct yaffs_obj *in)
3903 list_del_init(&in->hard_links);
3904 return yaffs_generic_obj_del(in);
3966 /* Put the children in lost and found. */
4195 * We put it in unlinked dir to be cleaned up after the scanning
4212 struct yaffs_obj *in;
4216 in = yaffs_find_by_number(dev,
4219 if (in) {
4221 hl->variant.hardlink_variant.equiv_obj = in;
4222 list_add(&hl->hard_links, &in->hard_links);
4260 * Any unrooted objects are re-rooted in lost+found.
4261 * An object needs to be in one of:
4272 * deleted leaving the object "hanging" without being rooted in the
4295 /* Iterate through the objects in each hash entry,
4439 * * If the object name is missing, we then make one up in the form objnnn
4441 * * ASCII names are stored in the object header's name field from byte zero
4445 * The purpose of these is to save names in a way that can be read as
4450 * - If the name can fit in the ASCII character space then they are saved as
4452 * - If the name needs Unicode then the name is saved in Unicode
5074 /* Now count and subtract the number of dirty chunks in the cache. */