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];
#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
}
#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
}
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
}
#define BUG() do { yaffs_bug_fn(__FILE__, __LINE__); } while (0)
-#ifdef YAFFS_USE_32_BIT_TIME_T
+#ifdef CONFIG_YAFFS_USE_32_BIT_TIME_T
#define YTIME_T u32
#else
#define YTIME_T u64
#define CONFIG_YAFFS_PROVIDE_DEFS 1
#define CONFIG_YAFFSFS_PROVIDE_VALUES 1
#define CONFIG_YAFFS_DEFINES_TYPES 1
+#define CONFIG_YAFFS_USE_32_BIT_TIME_T 1
#define NO_Y_INLINE 1
#define loff_t off_t
obj = yaffs_get_equivalent_obj(obj);
if (obj != NULL) {
obj->dirty = 1;
- obj->yst_atime = (u32) actime;
- obj->yst_mtime = (u32) modtime;
- obj->yst_ctime = (u32) time(NULL);
+ obj->yst_atime = actime;
+ obj->yst_mtime = modtime;
+ obj->yst_ctime = time(NULL);
} else {
errno = EIO;
rv = -1;
mode = S_IFLNK |
((S_IRWXU | S_IRWXG | S_IRWXO) & ~rtems_filesystem_umask);
- created_link = yaffs_create_symlink(parent_dir, name, mode,
+ created_link = yaffs_create_symlink(parent_dir, name, mode,
geteuid(), getegid(), target);
if (created_link != NULL) {
free(ptr);
}
-u32 yaffsfs_CurrentTime(void)
+YTIME_T yaffsfs_CurrentTime(void)
{
return time(NULL);
}
{
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;
}
{
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;
}
yaffs_update_oh(obj, NULL, 1, 0, 0, NULL);
return YAFFS_OK;
-
}
int yaffs_get_attribs(struct yaffs_obj *obj, struct iattr *attr)
((val << 56) & 0xff00000000000000);
}
-//YTIME_T can be a 32 or 64 bit number.
-#if YAFFS_USE_32_BIT_TIME_T
- #define swap_ytime_t( val ) swap_u32(val)
-#else
- #define swap_ytime_t( val ) swap_u64(val)
-#endif
+static inline YTIME_T swap_ytime_t(YTIME_T val)
+{
+
+ if (sizeof(YTIME_T) == sizeof(u64))
+ return swap_u64(val);
+ else
+ return swap_u32(val);
+}
//swap a signed 32 bit integer.
#define swap_s32(val) \
return n_free;
}
+/*
+ * Marshalling functions to get the appropriate time values saved
+ * and restored to/from obj headers.
+ *
+ * Note that the WinCE time fields are used to store the 32-bit values.
+ */
+
+static void yaffs_oh_time_load(u32 *yst_time, u32 *win_time, YTIME_T timeval)
+{
+ u32 upper;
+ u32 lower;
+
+ lower = timeval & 0xffffffff;
+ if (sizeof(YTIME_T) > sizeof(u32))
+ upper = (timeval >> 32) & 0xffffffff;
+ else
+ upper = 0;
+
+ *yst_time = lower;
+ win_time[0] = lower;
+ win_time[1] = upper;
+}
+
+static YTIME_T yaffs_oh_time_fetch(const u32 *yst_time, const u32 *win_time)
+{
+ u32 upper;
+ u32 lower;
+
+ if (win_time[1] == 0xffffffff) {
+ upper = 0;
+ lower = *yst_time;
+ } else {
+ upper = win_time[1];
+ lower = win_time[0];
+ }
+ if (sizeof(YTIME_T) > sizeof(u32)) {
+ u64 ret;
+ ret = (((u64)upper) << 32) | lower;
+ return (YTIME_T) ret;
+
+ } else
+ return (YTIME_T) lower;
+}
+
+YTIME_T yaffs_oh_ctime_fetch(struct yaffs_obj_hdr *oh)
+{
+ return yaffs_oh_time_fetch(&oh->yst_ctime, oh->win_ctime);
+}
+
+YTIME_T yaffs_oh_mtime_fetch(struct yaffs_obj_hdr *oh)
+{
+ return yaffs_oh_time_fetch(&oh->yst_mtime, oh->win_mtime);
+}
+
+YTIME_T yaffs_oh_atime_fetch(struct yaffs_obj_hdr *oh)
+{
+ return yaffs_oh_time_fetch(&oh->yst_atime, oh->win_atime);
+}
+
+void yaffs_oh_ctime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
+{
+ yaffs_oh_time_load(&oh->yst_ctime, oh->win_ctime, obj->yst_ctime);
+}
+
+void yaffs_oh_mtime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
+{
+ yaffs_oh_time_load(&oh->yst_mtime, oh->win_mtime, obj->yst_mtime);
+}
+
+void yaffs_oh_atime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
+{
+ yaffs_oh_time_load(&oh->yst_atime, oh->win_atime, obj->yst_atime);
+}
+
/*
* Marshalling functions to get loff_t file sizes into and out of
u32 yst_rdev; /* stuff for block and char devices (major/min) */
+ /*
+ * WinCE times are no longer just used to store WinCE times.
+ * They are also used to store 64-bit times.
+ * We actually store and read the times in both places and use
+ * the best we can.
+ */
u32 win_ctime[2];
u32 win_atime[2];
u32 win_mtime[2];
int yaffs_find_chunk_in_file(struct yaffs_obj *in, int inode_chunk,
struct yaffs_ext_tags *tags);
+/*
+ *Time marshalling functions
+ */
+
+YTIME_T yaffs_oh_ctime_fetch(struct yaffs_obj_hdr *oh);
+YTIME_T yaffs_oh_mtime_fetch(struct yaffs_obj_hdr *oh);
+YTIME_T yaffs_oh_atime_fetch(struct yaffs_obj_hdr *oh);
+
+void yaffs_oh_ctime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh);
+void yaffs_oh_mtime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh);
+void yaffs_oh_atime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh);
+
/*
* Define LOFF_T_32_BIT if a 32-bit LOFF_T is being used.
* Not serious if you get this wrong - you might just get some warnings.
#define YUCHAR unsigned char
#define _Y(x) x
+#define YTIME_T u64
+
#define YAFFS_LOSTNFOUND_NAME "lost+found"
#define YAFFS_LOSTNFOUND_PREFIX "obj"
#define YCHAR char
#define YUCHAR unsigned char
#define _Y(x) x
+#define YTIME_T u64
+
#define YAFFS_LOSTNFOUND_NAME "lost+found"
#define YAFFS_LOSTNFOUND_PREFIX "obj"