yaffsfs.c: Fix NULL dereference in yaffs_unmount2_reldev()
[yaffs2.git] / direct / yaffs_attribs.c
index de80fe42fcd0e70f7a147707b900b55f67fcca9d..e798a88b3c3f96281ae54df9e6d80a7f6283e88f 100644 (file)
@@ -1,8 +1,7 @@
 /*
  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
  *
- * Copyright (C) 2002-2011 Aleph One Ltd.
- *   for Toby Churchill Ltd and Brightstar Engineering
+ * Copyright (C) 2002-2018 Aleph One Ltd.
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
  *
@@ -16,6 +15,7 @@
 
 void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
 {
+
 #ifdef CONFIG_YAFFS_WINCE
        obj->win_atime[0] = oh->win_atime[0];
        obj->win_ctime[0] = oh->win_ctime[0];
@@ -26,9 +26,11 @@ void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
 #else
        obj->yst_uid = oh->yst_uid;
        obj->yst_gid = oh->yst_gid;
-       obj->yst_atime = oh->yst_atime;
-       obj->yst_mtime = oh->yst_mtime;
-       obj->yst_ctime = oh->yst_ctime;
+
+        obj->yst_ctime = yaffs_oh_ctime_fetch(oh);
+        obj->yst_mtime = yaffs_oh_mtime_fetch(oh);
+        obj->yst_atime = yaffs_oh_atime_fetch(oh);
+
        obj->yst_rdev = oh->yst_rdev;
 #endif
 }
@@ -46,9 +48,11 @@ void yaffs_load_attribs_oh(struct yaffs_obj_hdr *oh, struct yaffs_obj *obj)
 #else
        oh->yst_uid = obj->yst_uid;
        oh->yst_gid = obj->yst_gid;
-       oh->yst_atime = obj->yst_atime;
-       oh->yst_mtime = obj->yst_mtime;
-       oh->yst_ctime = obj->yst_ctime;
+
+        yaffs_oh_ctime_load(obj, oh);
+        yaffs_oh_mtime_load(obj, oh);
+        yaffs_oh_atime_load(obj, oh);
+
        oh->yst_rdev = obj->yst_rdev;
 #endif
 }
@@ -82,27 +86,8 @@ void yaffs_load_current_time(struct yaffs_obj *obj, int do_a, int do_c)
 
        obj->yst_mtime = Y_CURRENT_TIME;
        if (do_a)
-               obj->yst_atime = obj->yst_atime;
+               obj->yst_atime = obj->yst_mtime;
        if (do_c)
-               obj->yst_ctime = obj->yst_atime;
+               obj->yst_ctime = obj->yst_mtime;
 #endif
 }
-
-static Y_LOFF_T yaffs_get_file_size(struct yaffs_obj *obj)
-{
-       YCHAR *alias = NULL;
-       obj = yaffs_get_equivalent_obj(obj);
-
-       switch (obj->variant_type) {
-       case YAFFS_OBJECT_TYPE_FILE:
-               return obj->variant.file_variant.file_size;
-       case YAFFS_OBJECT_TYPE_SYMLINK:
-               alias = obj->variant.symlink_variant.alias;
-               if (!alias)
-                       return 0;
-               return yaffs_strnlen(alias, YAFFS_MAX_ALIAS_LENGTH);
-       default:
-               return 0;
-       }
-}
-