Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's the code to get the native block size:</p> <pre><code>#include &lt;sys/stat.h&gt; #include &lt;IOKit/IOKitLib.h&gt; #include &lt;IOKit/IOBSD.h&gt; #include &lt;IOKit/storage/IOMedia.h&gt; #include &lt;CoreFoundation/CoreFoundation.h&gt; // look up device number with stat struct stat stats; if (stat(path, &amp;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, &amp;bsd_major); values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &amp;bsd_minor); CFDictionaryRef matchingDictionary; matchingDictionary = CFDictionaryCreate(kCFAllocatorDefault, &amp;keys, &amp;values, sizeof(keys) / sizeof(*keys), &amp;kCFTypeDictionaryKeyCallBacks, &amp;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, &amp;blockSize); CFRelease(blockSizeProperty); // blockSize is the native block size of the device </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload