- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想找出 cocoa 应用程序中使用的 IO 介质的自然 block 大小。我在 IOMedia.cpp 中看到一个名为“getPreferredBlockSize()”的函数,据说它可以提供我的 block 大小。请你们解释一下如何在我的应用程序中使用此功能,或者是否有任何其他方法可以使用它来找到底层 IO 媒体的自然 block 大小。
谢谢
最佳答案
这是获取 native block 大小的代码:
#include <sys/stat.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOBSD.h>
#include <IOKit/storage/IOMedia.h>
#include <CoreFoundation/CoreFoundation.h>
// look up device number with stat
struct stat stats;
if (stat(path, &stats) != 0) {
return;
}
// use st_rdev instead of st_dev if
// the path is a device (/dev/disk0)
int bsd_major = major(stats.st_dev);
int bsd_minor = minor(stats.st_dev);
CFTypeRef keys[2] = { CFSTR(kIOBSDMajorKey), CFSTR(kIOBSDMinorKey) };
CFTypeRef values[2];
values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &bsd_major);
values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &bsd_minor);
CFDictionaryRef matchingDictionary;
matchingDictionary = CFDictionaryCreate(kCFAllocatorDefault,
&keys, &values,
sizeof(keys) / sizeof(*keys),
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFRelease(values[0]);
CFRelease(values[1]);
// IOServiceGetMatchingService uses up one reference to the dictionary
io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault,
matchingDictionary);
if (!service) {
return;
}
CFNumberRef blockSizeProperty;
blockSizeProperty = (CFNumberRef)IORegistryEntryCreateCFProperty(service,
CFSTR(kIOMediaPreferredBlockSizeKey),
kCFAllocatorDefault, 0);
if (!blockSizeProperty) {
return;
}
int blockSize;
CFNumberGetValue(blockSizeProperty, kCFNumberIntType, &blockSize);
CFRelease(blockSizeProperty);
// blockSize is the native block size of the device
关于cocoa - 查找文件句柄使用的媒体的自然 block 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1246315/
我设置了 Helm 柄和 Helm 柄。我有tiller-deploy。昨天,我可以定期运行了。但今天我收到此错误消息 Error: could not find a ready tiller pod
我以前已将分er安装到特定的 namespace 中。 我设置了一个环境变量来设置'tiller'命名空间-但我不记得该环境变量的名称-而且似乎无法通过网络搜索找到它。 这是什么 key ? 最佳答案
当我在 View 模型中使用如下界面时 class MainViewModel @ViewModelInject constructor( private val trafficImagesR
我正在尝试找到如何在某个 fragment 相关场景中定义 Hilt 的解决方案。我有以下设置: Activity 父 fragment 1 子 fragment 1 子 fragment 2 ...
Hilt 指出如果没有@Provides 注解就不能提供这个接口(interface): interface PlannedListRepository { fun getAllLists()
我的问题非常简单明了:两个注释/示例之间有什么区别: 例子一 @Singleton class MySingletonClass() {} @Module @InstallIn(FragmentCom
我是一名优秀的程序员,十分优秀!