]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libxfs/darwin.c
2 * Copyright (c) 2003,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <sys/mount.h>
22 #include <sys/ioctl.h>
23 #include <sys/sysctl.h>
26 int platform_has_uuid
= 1;
27 extern char *progname
;
30 platform_check_ismounted(char *name
, char *block
, struct stat
*s
, int verbose
)
36 platform_check_iswritable(char *name
, char *block
, struct stat
*s
)
40 if ((fd
= open(block
, O_RDONLY
, 0)) < 0) {
41 fprintf(stderr
, _("%s: "
42 "error opening the device special file \"%s\": %s\n"),
43 progname
, block
, strerror(errno
));
47 if (ioctl(fd
, DKIOCISWRITABLE
, &writable
) < 0) {
48 fprintf(stderr
, _("%s: can't tell if \"%s\" is writable: %s\n"),
49 progname
, block
, strerror(errno
));
57 platform_set_blocksize(int fd
, char *path
, dev_t device
, int blocksize
, int fatal
)
63 platform_flush_device(int fd
, dev_t device
)
65 ioctl(fd
, DKIOCSYNCHRONIZECACHE
, NULL
);
69 platform_findsizes(char *path
, int fd
, long long *sz
, int *bsz
)
74 if (fstat(fd
, &st
) < 0) {
76 _("%s: cannot stat the device file \"%s\": %s\n"),
77 progname
, path
, strerror(errno
));
80 if ((st
.st_mode
& S_IFMT
) == S_IFREG
) {
81 *sz
= (long long)(st
.st_size
>> 9);
85 if (ioctl(fd
, DKIOCGETBLOCKCOUNT
, &size
) < 0) {
86 fprintf(stderr
, _("%s: can't determine device size: %s\n"),
87 progname
, strerror(errno
));
90 *sz
= (long long)size
;
95 platform_findrawpath(char *path
)
101 platform_findblockpath(char *path
)
107 platform_direct_blockdev(void)
113 platform_align_blockdev(void)
115 return sizeof(void *);
122 size_t len
= sizeof(ncpu
);
123 static int mib
[2] = {CTL_HW
, HW_NCPU
};
125 if (sysctl(mib
, 2, &ncpu
, &len
, NULL
, 0) < 0)
132 platform_physmem(void)
134 unsigned long physmem
;
135 size_t len
= sizeof(physmem
);
136 static int mib
[2] = {CTL_HW
, HW_PHYSMEM
};
138 if (sysctl(mib
, 2, &physmem
, &len
, NULL
, 0) < 0) {
139 fprintf(stderr
, _("%s: can't determine memory size\n"),
143 return physmem
>> 10;