ACPI: delete unnecessary EC console messages
[linux-2.6/verdex.git] / fs / ntfs / quota.c
blob833df2a4e9fbaec5562483459b196ede324054e3
1 /*
2 * quota.c - NTFS kernel quota ($Quota) handling. Part of the Linux-NTFS
3 * project.
5 * Copyright (c) 2004 Anton Altaparmakov
7 * This program/include file is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program/include file is distributed in the hope that it will be
13 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program (in the main directory of the Linux-NTFS
19 * distribution in the file COPYING); if not, write to the Free Software
20 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifdef NTFS_RW
25 #include "index.h"
26 #include "quota.h"
27 #include "debug.h"
28 #include "ntfs.h"
30 /**
31 * ntfs_mark_quotas_out_of_date - mark the quotas out of date on an ntfs volume
32 * @vol: ntfs volume on which to mark the quotas out of date
34 * Mark the quotas out of date on the ntfs volume @vol and return TRUE on
35 * success and FALSE on error.
37 BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
39 ntfs_index_context *ictx;
40 QUOTA_CONTROL_ENTRY *qce;
41 const le32 qid = QUOTA_DEFAULTS_ID;
42 int err;
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;
51 down(&vol->quota_q_ino->i_sem);
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;
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;
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;
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;
78 ntfs_debug("Quota defaults flags = 0x%x.", le32_to_cpu(qce->flags));
79 /* If quotas are already marked out of date, no need to do anything. */
80 if (qce->flags & QUOTA_FLAG_OUT_OF_DATE)
81 goto set_done;
83 * If quota tracking is neither requested, nor enabled and there are no
84 * pending deletes, no need to mark the quotas out of date.
86 if (!(qce->flags & (QUOTA_FLAG_TRACKING_ENABLED |
87 QUOTA_FLAG_TRACKING_REQUESTED |
88 QUOTA_FLAG_PENDING_DELETES)))
89 goto set_done;
91 * Set the QUOTA_FLAG_OUT_OF_DATE bit thus marking quotas out of date.
92 * This is verified on WinXP to be sufficient to cause windows to
93 * rescan the volume on boot and update all quota entries.
95 qce->flags |= QUOTA_FLAG_OUT_OF_DATE;
96 /* Ensure the modified flags are written to disk. */
97 ntfs_index_entry_flush_dcache_page(ictx);
98 ntfs_index_entry_mark_dirty(ictx);
99 set_done:
100 ntfs_index_ctx_put(ictx);
101 up(&vol->quota_q_ino->i_sem);
103 * We set the flag so we do not try to mark the quotas out of date
104 * again on remount.
106 NVolSetQuotaOutOfDate(vol);
107 done:
108 ntfs_debug("Done.");
109 return TRUE;
110 err_out:
111 if (ictx)
112 ntfs_index_ctx_put(ictx);
113 up(&vol->quota_q_ino->i_sem);
114 return FALSE;
117 #endif /* NTFS_RW */