]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_notification.c
xnu-792.10.96.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_notification.c
1 /*
2 * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 #include <sys/systm.h>
24 #include <sys/kernel.h>
25 #include <sys/file.h>
26 #include <sys/dirent.h>
27 #include <sys/stat.h>
28 #include <sys/mount.h>
29 #include <sys/vnode.h>
30 #include <sys/malloc.h>
31 #include <sys/ubc.h>
32 #include <sys/quota.h>
33
34 #include <sys/kdebug.h>
35
36 #include "hfs.h"
37 #include "hfs_catalog.h"
38 #include "hfs_cnode.h"
39 #include "hfs_dbg.h"
40 #include "hfs_mount.h"
41 #include "hfs_quota.h"
42 #include "hfs_endian.h"
43
44 #include "hfscommon/headers/BTreesInternal.h"
45 #include "hfscommon/headers/FileMgrInternal.h"
46
47
48
49 void hfs_generate_volume_notifications(struct hfsmount *hfsmp) {
50 ExtendedVCB *vcb = HFSTOVCB(hfsmp);
51 fsid_t fsid;
52
53 fsid.val[0] = (long)hfsmp->hfs_raw_dev;
54 fsid.val[1] = (long)vfs_typenum(HFSTOVFS(hfsmp));
55
56 if (hfsmp->hfs_notification_conditions & VQ_LOWDISK) {
57 /* Check to see whether the free space is back above the minimal level: */
58 if (hfs_freeblks(hfsmp, 1) > hfsmp->hfs_freespace_notify_desiredlevel) {
59 hfsmp->hfs_notification_conditions &= ~VQ_LOWDISK;
60 vfs_event_signal(&fsid, hfsmp->hfs_notification_conditions, NULL);
61 }
62 } else {
63 /* Check to see whether the free space fell below the requested limit: */
64 if (hfs_freeblks(hfsmp, 1) < hfsmp->hfs_freespace_notify_warninglimit) {
65 hfsmp->hfs_notification_conditions |= VQ_LOWDISK;
66 vfs_event_signal(&fsid, hfsmp->hfs_notification_conditions, NULL);
67 }
68 };
69 }