]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libfrog/darwin.c
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2003,2005 Silicon Graphics, Inc.
10 #include <sys/ioctl.h>
11 #include <sys/sysctl.h>
14 int platform_has_uuid
= 1;
15 extern char *progname
;
17 #warning "Darwin support is deprecated and planned for removal in July 2018"
18 #warning "Contact linux-xfs@vger.kernel.org if you'd like to maintain this port"
19 #error "Remove this line if you'd like to continue the build"
22 platform_check_ismounted(char *name
, char *block
, struct stat
*s
, int verbose
)
28 platform_check_iswritable(char *name
, char *block
, struct stat
*s
)
32 if ((fd
= open(block
, O_RDONLY
, 0)) < 0) {
33 fprintf(stderr
, _("%s: "
34 "error opening the device special file \"%s\": %s\n"),
35 progname
, block
, strerror(errno
));
39 if (ioctl(fd
, DKIOCISWRITABLE
, &writable
) < 0) {
40 fprintf(stderr
, _("%s: can't tell if \"%s\" is writable: %s\n"),
41 progname
, block
, strerror(errno
));
49 platform_set_blocksize(int fd
, char *path
, dev_t device
, int blocksize
, int fatal
)
55 platform_flush_device(int fd
, dev_t device
)
57 ioctl(fd
, DKIOCSYNCHRONIZECACHE
, NULL
);
61 platform_findsizes(char *path
, int fd
, long long *sz
, int *bsz
)
66 if (fstat(fd
, &st
) < 0) {
68 _("%s: cannot stat the device file \"%s\": %s\n"),
69 progname
, path
, strerror(errno
));
72 if ((st
.st_mode
& S_IFMT
) == S_IFREG
) {
73 *sz
= (long long)(st
.st_size
>> 9);
77 if (ioctl(fd
, DKIOCGETBLOCKCOUNT
, &size
) < 0) {
78 fprintf(stderr
, _("%s: can't determine device size: %s\n"),
79 progname
, strerror(errno
));
82 *sz
= (long long)size
;
87 platform_findrawpath(char *path
)
93 platform_findblockpath(char *path
)
99 platform_direct_blockdev(void)
105 platform_align_blockdev(void)
107 return sizeof(void *);
114 size_t len
= sizeof(ncpu
);
115 static int mib
[2] = {CTL_HW
, HW_NCPU
};
117 if (sysctl(mib
, 2, &ncpu
, &len
, NULL
, 0) < 0)
124 platform_physmem(void)
126 unsigned long physmem
;
127 size_t len
= sizeof(physmem
);
128 static int mib
[2] = {CTL_HW
, HW_PHYSMEM
};
130 if (sysctl(mib
, 2, &physmem
, &len
, NULL
, 0) < 0) {
131 fprintf(stderr
, _("%s: can't determine memory size\n"),
135 return physmem
>> 10;