1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifdef NTFS_RW
24
25#include "index.h"
26#include "quota.h"
27#include "debug.h"
28#include "ntfs.h"
29
30
31
32
33
34
35
36
37bool ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
38{
39 ntfs_index_context *ictx;
40 QUOTA_CONTROL_ENTRY *qce;
41 const le32 qid = QUOTA_DEFAULTS_ID;
42 int err;
43
44 ntfs_debug("Entering.");
45 if (NVolQuotaOutOfDate(vol))
46 goto done;
47 if (!vol->quota_ino || !vol->quota_q_ino) {
48 ntfs_error(vol->sb, "Quota inodes are not open.");
49 return false;
50 }
51 mutex_lock(&vol->quota_q_ino->i_mutex);
52 ictx = ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino));
53 if (!ictx) {
54 ntfs_error(vol->sb, "Failed to get index context.");
55 goto err_out;
56 }
57 err = ntfs_index_lookup(&qid, sizeof(qid), ictx);
58 if (err) {
59 if (err == -ENOENT)
60 ntfs_error(vol->sb, "Quota defaults entry is not "
61 "present.");
62 else
63 ntfs_error(vol->sb, "Lookup of quota defaults entry "
64 "failed.");
65 goto err_out;
66 }
67 if (ictx->data_len < offsetof(QUOTA_CONTROL_ENTRY, sid)) {
68 ntfs_error(vol->sb, "Quota defaults entry size is invalid. "
69 "Run chkdsk.");
70 goto err_out;
71 }
72 qce = (QUOTA_CONTROL_ENTRY*)ictx->data;
73 if (le32_to_cpu(qce->version) != QUOTA_VERSION) {
74 ntfs_error(vol->sb, "Quota defaults entry version 0x%x is not "
75 "supported.", le32_to_cpu(qce->version));
76 goto err_out;
77 }
78 ntfs_debug("Quota defaults flags = 0x%x.", le32_to_cpu(qce->flags));
79
80 if (qce->flags & QUOTA_FLAG_OUT_OF_DATE)
81 goto set_done;
82
83
84
85
86 if (!(qce->flags & (QUOTA_FLAG_TRACKING_ENABLED |
87 QUOTA_FLAG_TRACKING_REQUESTED |
88 QUOTA_FLAG_PENDING_DELETES)))
89 goto set_done;
90
91
92
93
94
95 qce->flags |= QUOTA_FLAG_OUT_OF_DATE;
96
97 ntfs_index_entry_flush_dcache_page(ictx);
98 ntfs_index_entry_mark_dirty(ictx);
99set_done:
100 ntfs_index_ctx_put(ictx);
101 mutex_unlock(&vol->quota_q_ino->i_mutex);
102
103
104
105
106 NVolSetQuotaOutOfDate(vol);
107done:
108 ntfs_debug("Done.");
109 return true;
110err_out:
111 if (ictx)
112 ntfs_index_ctx_put(ictx);
113 mutex_unlock(&vol->quota_q_ino->i_mutex);
114 return false;
115}
116
117#endif
118