/* Function to calculate chunk and offset */
-static inline void yaffs_addr_to_chunk(struct yaffs_dev *dev, loff_t addr,
- int *chunk_out, u32 *offset_out)
+void yaffs_addr_to_chunk(struct yaffs_dev *dev, loff_t addr,
+ int *chunk_out, u32 *offset_out)
{
int chunk;
u32 offset;
yaffs_trace(YAFFS_TRACE_ERROR,
"**>> yaffs write required %d attempts",
attempts);
- dev->n_retired_writes += (attempts - 1);
+ dev->n_retried_writes += (attempts - 1);
}
return chunk;
/* Update file size */
if (object->variant_type == YAFFS_OBJECT_TYPE_FILE) {
- oh->file_size =
+ yaffs_oh_size_load( oh,
+ object->variant.file_variant.file_size);
+ tags.extra_file_size =
object->variant.file_variant.file_size;
- tags.extra_length = oh->file_size;
}
yaffs_verify_oh(object, oh, &tags, 1);
}
} else {
#else
+ dev = dev;
{
#endif
strncpy(name, oh_name, buff_size - 1);
}
} else {
#else
+ dev = dev;
{
#endif
strncpy(oh_name, name, YAFFS_MAX_NAME_LENGTH - 1);
u8 *buffer = NULL;
YCHAR old_name[YAFFS_MAX_NAME_LENGTH + 1];
struct yaffs_obj_hdr *oh = NULL;
+ loff_t file_size = 0;
strcpy(old_name, _Y("silly old name"));
/* Should not happen */
break;
case YAFFS_OBJECT_TYPE_FILE:
- oh->file_size =
- (oh->parent_obj_id == YAFFS_OBJECTID_DELETED ||
- oh->parent_obj_id == YAFFS_OBJECTID_UNLINKED) ?
- 0 : in->variant.file_variant.file_size;
+ if (oh->parent_obj_id != YAFFS_OBJECTID_DELETED &&
+ oh->parent_obj_id != YAFFS_OBJECTID_UNLINKED)
+ file_size = in->variant.file_variant.file_size;
+ yaffs_oh_size_load(oh, file_size);
break;
case YAFFS_OBJECT_TYPE_HARDLINK:
oh->equiv_id = in->variant.hardlink_variant.equiv_id;
/* Add extra info for file header */
new_tags.extra_available = 1;
new_tags.extra_parent_id = oh->parent_obj_id;
- new_tags.extra_length = oh->file_size;
+ new_tags.extra_file_size = file_size;
new_tags.extra_is_shrink = oh->is_shrink;
new_tags.extra_equiv_id = oh->equiv_id;
new_tags.extra_shadows = (oh->shadows_obj > 0) ? 1 : 0;
int yaffs_resize_file(struct yaffs_obj *in, loff_t new_size)
{
struct yaffs_dev *dev = in->my_dev;
- int old_size = in->variant.file_variant.file_size;
+ loff_t old_size = in->variant.file_variant.file_size;
yaffs_flush_file_cache(in);
yaffs_invalidate_whole_cache(in);
return strnlen(name, YAFFS_MAX_NAME_LENGTH);
}
-int yaffs_get_obj_length(struct yaffs_obj *obj)
+loff_t yaffs_get_obj_length(struct yaffs_obj *obj)
{
/* Dereference any hard linking */
obj = yaffs_get_equivalent_obj(obj);
dev->n_page_writes = 0;
dev->n_erasures = 0;
dev->n_gc_copies = 0;
- dev->n_retired_writes = 0;
+ dev->n_retried_writes = 0;
dev->n_retired_blocks = 0;
return n_free;
}
+
+/*\
+ * Marshalling functions to get loff_t file sizes into aand out of
+ * object headers.
+ */
+void yaffs_oh_size_load(struct yaffs_obj_hdr *oh, loff_t fsize)
+{
+ oh->file_size_low = (fsize & 0xFFFFFFFF);
+ oh->file_size_high = ((fsize >> 32) & 0xFFFFFFFF);
+}
+
+loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh)
+{
+ loff_t retval;
+
+ if(~(oh->file_size_high))
+ retval = (((loff_t) oh->file_size_high) << 32) |
+ (((loff_t) oh->file_size_low) & 0xFFFFFFFF);
+ else
+ retval = (loff_t) oh->file_size_low;
+
+ return retval;
+}