Fix copyright
[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 #ifdef CONFIG_YAFFS_WINCE
19         obj->win_atime[0] = oh->win_atime[0];
20         obj->win_ctime[0] = oh->win_ctime[0];
21         obj->win_mtime[0] = oh->win_mtime[0];
22         obj->win_atime[1] = oh->win_atime[1];
23         obj->win_ctime[1] = oh->win_ctime[1];
24         obj->win_mtime[1] = oh->win_mtime[1];
25 #else
26         obj->yst_uid = oh->yst_uid;
27         obj->yst_gid = oh->yst_gid;
28         obj->yst_atime = oh->yst_atime;
29         obj->yst_mtime = oh->yst_mtime;
30         obj->yst_ctime = oh->yst_ctime;
31         obj->yst_rdev = oh->yst_rdev;
32 #endif
33 }
34
35
36 void yaffs_load_attribs_oh(struct yaffs_obj_hdr *oh, struct yaffs_obj *obj)
37 {
38 #ifdef CONFIG_YAFFS_WINCE
39         oh->win_atime[0] = obj->win_atime[0];
40         oh->win_ctime[0] = obj->win_ctime[0];
41         oh->win_mtime[0] = obj->win_mtime[0];
42         oh->win_atime[1] = obj->win_atime[1];
43         oh->win_ctime[1] = obj->win_ctime[1];
44         oh->win_mtime[1] = obj->win_mtime[1];
45 #else
46         oh->yst_uid = obj->yst_uid;
47         oh->yst_gid = obj->yst_gid;
48         oh->yst_atime = obj->yst_atime;
49         oh->yst_mtime = obj->yst_mtime;
50         oh->yst_ctime = obj->yst_ctime;
51         oh->yst_rdev = obj->yst_rdev;
52 #endif
53 }
54
55 void yaffs_attribs_init(struct yaffs_obj *obj, u32 gid, u32 uid, u32 rdev)
56 {
57
58 #ifdef CONFIG_YAFFS_WINCE
59         yfsd_win_file_time_now(obj->win_atime);
60         obj->win_ctime[0] = obj->win_mtime[0] = obj->win_atime[0];
61         obj->win_ctime[1] = obj->win_mtime[1] = obj->win_atime[1];
62
63 #else
64         yaffs_load_current_time(obj, 1, 1);
65         obj->yst_rdev = rdev;
66         obj->yst_uid = uid;
67         obj->yst_gid = gid;
68 #endif
69 }
70
71 void yaffs_load_current_time(struct yaffs_obj *obj, int do_a, int do_c)
72 {
73 #ifdef CONFIG_YAFFS_WINCE
74         yfsd_win_file_time_now(obj->win_atime);
75         obj->win_ctime[0] = obj->win_mtime[0] =
76             obj->win_atime[0];
77         obj->win_ctime[1] = obj->win_mtime[1] =
78             obj->win_atime[1];
79
80 #else
81
82         obj->yst_mtime = Y_CURRENT_TIME;
83         if (do_a)
84                 obj->yst_atime = obj->yst_atime;
85         if (do_c)
86                 obj->yst_ctime = obj->yst_atime;
87 #endif
88 }