Re: [Yaffs] Direct Interface, files contain zero when mount…

Top Page
Attachments:
Message as email
+ (text/plain)
+ 0001-Some-minor-fixes-for-smooth-compilation-of-direct-interface.patch (text/plain)
Delete this message
Reply to this message
Author: Stéphane Lesage
Date:  
To: yaffs
Subject: Re: [Yaffs] Direct Interface, files contain zero when mounting without checkpoint

>Could you try the changes in the 32-bit-loff_t branch:
>http://yaffs.net/gitweb?p=yaffs2.git;a=shortlog;h=refs/heads/32-bit-loff_t
>See if that works for you.


Ok, it works.
I don't this inevitable runtime comparison of sizeof(loff_t), but fortunately it's optimized away.
I would also add one in yaffs_oh_size_load().

Can you consider the attached patch ?
It contains some minor fixes, mainly for direct interface smooth compilation.


--
Stephane Lesage

From 3df8b9045582b1ca0af81b73eeb0de2f26bcdc02 Mon Sep 17 00:00:00 2001
From: unknown <lesages@lesages>
Date: Sat, 9 Jun 2012 16:42:42 +0200
Subject: [PATCH] Some minor fixes for smooth compilation of direct interface

---
 direct/yaffs_nandif.c |    2 +-
 direct/yaffsfs.h      |   11 +++++++++++
 direct/yportenv.h     |    2 +-
 yaffs_checkptrw.c     |    4 ++--
 yaffs_guts.c          |   17 ++++++++++-------
 yaffs_nameval.c       |    4 ++--
 yaffs_nand.h          |    2 +-
 7 files changed, 28 insertions(+), 14 deletions(-)


diff --git a/direct/yaffs_nandif.c b/direct/yaffs_nandif.c
index 3f1de6d..06a3a71 100644
--- a/direct/yaffs_nandif.c
+++ b/direct/yaffs_nandif.c
@@ -210,7 +210,7 @@ struct yaffs_dev *
                     const struct ynandif_Geometry *geometry)
 {
     YCHAR *clonedName = malloc(sizeof(YCHAR) *
-                (strnlen(name, YAFFS_MAX_NAME_LENGTH)+1));
+                (yaffs_strnlen(name, YAFFS_MAX_NAME_LENGTH)+1));
     struct yaffs_dev *dev = malloc(sizeof(struct yaffs_dev));
     struct yaffs_param *param;


diff --git a/direct/yaffsfs.h b/direct/yaffsfs.h
index c20da16..2257e98 100644
--- a/direct/yaffsfs.h
+++ b/direct/yaffsfs.h
@@ -34,6 +34,12 @@
     ( (sizeof(loff_t) < 8) ? YAFFS_MAX_FILE_SIZE_32 : (0x800000000LL - 1) )



+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
 struct yaffs_dirent {
     long d_ino;            /* inode number */
     off_t d_off;            /* offset to this dirent */
@@ -207,4 +213,9 @@ int yaffs_set_error(int error);
 /* Trace control functions */
 unsigned  yaffs_set_trace(unsigned tm);
 unsigned  yaffs_get_trace(void);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/direct/yportenv.h b/direct/yportenv.h
index b47a4d6..abc761b 100644
--- a/direct/yportenv.h
+++ b/direct/yportenv.h
@@ -22,7 +22,7 @@
 #ifdef CONFIG_YAFFS_DEFINES_TYPES
 typedef unsigned char u8;
 typedef unsigned short u16;
-typedef unsigned u32;
+typedef unsigned int u32;
 #endif



diff --git a/yaffs_checkptrw.c b/yaffs_checkptrw.c
index d897044..926f90c 100644
--- a/yaffs_checkptrw.c
+++ b/yaffs_checkptrw.c
@@ -149,8 +149,8 @@ static void yaffs2_checkpt_find_block(struct yaffs_dev *dev)
             dev->param.read_chunk_tags_fn(dev, realigned_chunk,
                               NULL, &tags);
             yaffs_trace(YAFFS_TRACE_CHECKPOINT,
-                "find next checkpt block: search: block %d state %d oid %d seq %d eccr %d",
-                i, (int) state,
+                "find next checkpt block: search: block %d oid %d seq %d eccr %d",
+                i,
                 tags.obj_id, tags.seq_number,
                 tags.ecc_result);


diff --git a/yaffs_guts.c b/yaffs_guts.c
index f3bc419..7186f3a 100644
--- a/yaffs_guts.c
+++ b/yaffs_guts.c
@@ -676,7 +676,7 @@ void yaffs_set_obj_name(struct yaffs_obj *obj, const YCHAR * name)
 {
     memset(obj->short_name, 0, sizeof(obj->short_name));
     if (name &&
-        strnlen(name, YAFFS_SHORT_NAME_LENGTH + 1) <=
+        yaffs_strnlen(name, YAFFS_SHORT_NAME_LENGTH + 1) <=
         YAFFS_SHORT_NAME_LENGTH)
         strcpy(obj->short_name, name);
     else
@@ -2045,7 +2045,7 @@ YCHAR *yaffs_clone_str(const YCHAR *str)
     if (!str)
         str = _Y("");


-    len = strnlen(str, YAFFS_MAX_ALIAS_LENGTH);
+    len = yaffs_strnlen(str, YAFFS_MAX_ALIAS_LENGTH);
     new_str = kmalloc((len + 1) * sizeof(YCHAR), GFP_NOFS);
     if (new_str) {
         strncpy(new_str, str, len);
@@ -4093,7 +4093,7 @@ int yaffs_rename_obj(struct yaffs_obj *old_dir, const YCHAR *old_name,
         force = 1;
 #endif


-    if (strnlen(new_name, YAFFS_MAX_NAME_LENGTH + 1) >
+    if (yaffs_strnlen(new_name, YAFFS_MAX_NAME_LENGTH + 1) >
         YAFFS_MAX_NAME_LENGTH)
         /* ENAMETOOLONG */
         return YAFFS_FAIL;
@@ -4420,7 +4420,7 @@ static void yaffs_fix_null_name(struct yaffs_obj *obj, YCHAR *name,
                 int buffer_size)
 {
     /* Create an object name if we could not find one. */
-    if (strnlen(name, YAFFS_MAX_NAME_LENGTH) == 0) {
+    if (yaffs_strnlen(name, YAFFS_MAX_NAME_LENGTH) == 0) {
         YCHAR local_name[20];
         YCHAR num_string[20];
         YCHAR *x = &num_string[19];
@@ -4467,7 +4467,7 @@ int yaffs_get_obj_name(struct yaffs_obj *obj, YCHAR *name, int buffer_size)


     yaffs_fix_null_name(obj, name, buffer_size);


-    return strnlen(name, YAFFS_MAX_NAME_LENGTH);
+    return yaffs_strnlen(name, YAFFS_MAX_NAME_LENGTH);
 }


 loff_t yaffs_get_obj_length(struct yaffs_obj *obj)
@@ -4480,7 +4480,7 @@ loff_t yaffs_get_obj_length(struct yaffs_obj *obj)
     if (obj->variant_type == YAFFS_OBJECT_TYPE_SYMLINK) {
         if (!obj->variant.symlink_variant.alias)
             return 0;
-        return strnlen(obj->variant.symlink_variant.alias,
+        return yaffs_strnlen(obj->variant.symlink_variant.alias,
                      YAFFS_MAX_ALIAS_LENGTH);
     } else {
         /* Only a directory should drop through to here */
@@ -5018,7 +5018,10 @@ int yaffs_get_n_free_chunks(struct yaffs_dev *dev)
 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);
+    if (sizeof(loff_t) >= 8)
+        oh->file_size_high = ((fsize >> 32) & 0xFFFFFFFF);
+    else
+        oh->file_size_high = 0;
 }


 loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh)
diff --git a/yaffs_nameval.c b/yaffs_nameval.c
index 4bdf4ed..d85f8e6 100644
--- a/yaffs_nameval.c
+++ b/yaffs_nameval.c
@@ -90,7 +90,7 @@ int nval_set(char *xb, int xb_size, const YCHAR *name, const char *buf,
         int bsize, int flags)
 {
     int pos;
-    int namelen = strnlen(name, xb_size);
+    int namelen = yaffs_strnlen(name, xb_size);
     int reclen;
     int size_exist = 0;
     int space;
@@ -179,7 +179,7 @@ int nval_list(const char *xb, int xb_size, char *buf, int bsize)
         !filled) {
         pos += sizeof(int);
         size -= sizeof(int);
-        name_len = strnlen((YCHAR *) (xb + pos), size);
+        name_len = yaffs_strnlen((YCHAR *) (xb + pos), size);
         if (ncopied + name_len + 1 < bsize) {
             memcpy(buf, xb + pos, name_len * sizeof(YCHAR));
             buf += name_len;
diff --git a/yaffs_nand.h b/yaffs_nand.h
index 7134662..4f206c7 100644
--- a/yaffs_nand.h
+++ b/yaffs_nand.h
@@ -29,7 +29,7 @@ int yaffs_mark_bad(struct yaffs_dev *dev, int block_no);
 int yaffs_query_init_block_state(struct yaffs_dev *dev,
                  int block_no,
                  enum yaffs_block_state *state,
-                 unsigned *seq_number);
+                 u32 *seq_number);


int yaffs_erase_block(struct yaffs_dev *dev, int flash_block);

--
1.7.4.msysgit.0