]>
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
;
29 #warning "Darwin support is deprecated and planned for removal in July 2018"
30 #warning "Contact linux-xfs@vger.kernel.org if you'd like to maintain this port"
31 #error "Remove this line if you'd like to continue the build"
34 platform_check_ismounted(char *name
, char *block
, struct stat
*s
, int verbose
)
40 platform_check_iswritable(char *name
, char *block
, struct stat
*s
)
44 if ((fd
= open(block
, O_RDONLY
, 0)) < 0) {
45 fprintf(stderr
, _("%s: "
46 "error opening the device special file \"%s\": %s\n"),
47 progname
, block
, strerror(errno
));
51 if (ioctl(fd
, DKIOCISWRITABLE
, &writable
) < 0) {
52 fprintf(stderr
, _("%s: can't tell if \"%s\" is writable: %s\n"),
53 progname
, block
, strerror(errno
));
61 platform_set_blocksize(int fd
, char *path
, dev_t device
, int blocksize
, int fatal
)
67 platform_flush_device(int fd
, dev_t device
)
69 ioctl(fd
, DKIOCSYNCHRONIZECACHE
, NULL
);
73 platform_findsizes(char *path
, int fd
, long long *sz
, int *bsz
)
78 if (fstat(fd
, &st
) < 0) {
80 _("%s: cannot stat the device file \"%s\": %s\n"),
81 progname
, path
, strerror(errno
));
84 if ((st
.st_mode
& S_IFMT
) == S_IFREG
) {
85 *sz
= (long long)(st
.st_size
>> 9);
89 if (ioctl(fd
, DKIOCGETBLOCKCOUNT
, &size
) < 0) {
90 fprintf(stderr
, _("%s: can't determine device size: %s\n"),
91 progname
, strerror(errno
));
94 *sz
= (long long)size
;
99 platform_findrawpath(char *path
)
105 platform_findblockpath(char *path
)
111 platform_direct_blockdev(void)
117 platform_align_blockdev(void)
119 return sizeof(void *);
126 size_t len
= sizeof(ncpu
);
127 static int mib
[2] = {CTL_HW
, HW_NCPU
};
129 if (sysctl(mib
, 2, &ncpu
, &len
, NULL
, 0) < 0)
136 platform_physmem(void)
138 unsigned long physmem
;
139 size_t len
= sizeof(physmem
);
140 static int mib
[2] = {CTL_HW
, HW_PHYSMEM
};
142 if (sysctl(mib
, 2, &physmem
, &len
, NULL
, 0) < 0) {
143 fprintf(stderr
, _("%s: can't determine memory size\n"),
147 return physmem
>> 10;