Merge remote-tracking branch 'origin/64_and_32_bit_time_tests'
[yaffs2.git] / direct / yaffs_attribs.c
1 /*
2  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2018 Aleph One Ltd.
5  *
6  * Created by Charles Manning <charles@aleph1.co.uk>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12
13 #include "yaffs_attribs.h"
14
15
16 void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
17 {
18
19 #ifdef CONFIG_YAFFS_WINCE
20         obj->win_atime[0] = oh->win_atime[0];
21         obj->win_ctime[0] = oh->win_ctime[0];
22         obj->win_mtime[0] = oh->win_mtime[0];
23         obj->win_atime[1] = oh->win_atime[1];
24         obj->win_ctime[1] = oh->win_ctime[1];
25         obj->win_mtime[1] = oh->win_mtime[1];
26 #else
27         obj->yst_uid = oh->yst_uid;
28         obj->yst_gid = oh->yst_gid;
29
30         obj->yst_ctime = yaffs_oh_ctime_fetch(oh);
31         obj->yst_mtime = yaffs_oh_mtime_fetch(oh);
32         obj->yst_atime = yaffs_oh_atime_fetch(oh);
33
34         obj->yst_rdev = oh->yst_rdev;
35 #endif
36 }
37
38
39 void yaffs_load_attribs_oh(struct yaffs_obj_hdr *oh, struct yaffs_obj *obj)
40 {
41 #ifdef CONFIG_YAFFS_WINCE
42         oh->win_atime[0] = obj->win_atime[0];
43         oh->win_ctime[0] = obj->win_ctime[0];
44         oh->win_mtime[0] = obj->win_mtime[0];
45         oh->win_atime[1] = obj->win_atime[1];
46         oh->win_ctime[1] = obj->win_ctime[1];
47         oh->win_mtime[1] = obj->win_mtime[1];
48 #else
49         oh->yst_uid = obj->yst_uid;
50         oh->yst_gid = obj->yst_gid;
51
52         yaffs_oh_ctime_load(obj, oh);
53         yaffs_oh_mtime_load(obj, oh);
54         yaffs_oh_atime_load(obj, oh);
55
56         oh->yst_rdev = obj->yst_rdev;
57 #endif
58 }
59
60 void yaffs_attribs_init(struct yaffs_obj *obj, u32 gid, u32 uid, u32 rdev)
61 {
62
63 #ifdef CONFIG_YAFFS_WINCE
64         yfsd_win_file_time_now(obj->win_atime);
65         obj->win_ctime[0] = obj->win_mtime[0] = obj->win_atime[0];
66         obj->win_ctime[1] = obj->win_mtime[1] = obj->win_atime[1];
67
68 #else
69         yaffs_load_current_time(obj, 1, 1);
70         obj->yst_rdev = rdev;
71         obj->yst_uid = uid;
72         obj->yst_gid = gid;
73 #endif
74 }
75
76 void yaffs_load_current_time(struct yaffs_obj *obj, int do_a, int do_c)
77 {
78 #ifdef CONFIG_YAFFS_WINCE
79         yfsd_win_file_time_now(obj->win_atime);
80         obj->win_ctime[0] = obj->win_mtime[0] =
81             obj->win_atime[0];
82         obj->win_ctime[1] = obj->win_mtime[1] =
83             obj->win_atime[1];
84
85 #else
86
87         obj->yst_mtime = Y_CURRENT_TIME;
88         if (do_a)
89                 obj->yst_atime = obj->yst_mtime;
90         if (do_c)
91                 obj->yst_ctime = obj->yst_mtime;
92 #endif
93 }