OS X: How to programmatically find locked CoreStorageVolumes - disk

I have programmatically find out the status of the CoreStorage volumes.
Using IOServiceXyz / IORegistryXyz / ... methods do not work for locked volumes - that means if a user did not (yet) enter the password I do not see informations about this volume.
Using diskutil cs list and/or diskutil cs info helps but I have to start diskutil and scan the output. I do not like this way because it is a little bit slow (start a program using exec, ...)
Is there a better way?
At least diskutil can do it - so what API uses diskutil?
There is a libCoreStorage.dylib but I could not find any documentation about it. Where is it?
Any help is appreciated!
Regards

Related

monitor read/write to mtd (ubi) in linux

I looking for a way to monitor reads and writes to flash memory on an embedded board running buildroot.
problem is that cat /proc/diskstats only shows zeros in all columns (all the mtdblocks are there)
where else can I get that info? is there a missing package I need to add?
The topic of UBI statistics has been discussed recently on the linux-mtd mailing list, and a patch has been proposed: http://lists.infradead.org/pipermail/linux-mtd/2018-July/083030.html.

Add Disk space to C with batch Script

is it possible to add (Free)Diskspace to C: with a batch script?
You could write a script which deletes the most common places of temp files and caches on your system in order to free up space. Creating space out of nowhere is not possible though, obviously. If you do not need to automate the cleanup, you are probably better off using some cleanup tool for windows, simply google for "cleanup tool windows" for example.
If you want identify the most bloated places on your system, i found it very useful to use a tool showing you a sunburst diagram of places taking the most space on your hard drive. Such a tool would be f.i. http://www.jgoodies.com/freeware/jdiskreport/
If you are talking about resizing a partition, see e.g. https://www.partition-tool.com/resource/expand-windows-7-partition.htm for non automated options or http://www.itprotoday.com/management-mobility/formatting-and-resizing-partitions-diskpart for being able to do that in a batch file
yes you can extend Partition size using script but with Precaution
there are many tools available for doing the same task safely
but since you asked
Check Few Examples before proceeding.
Diskpart Scripts and Examples - Microsoft
User input for a DISKPART batch file
Extend a Basic Volume and Increase Disk Space
(for example)
Manually Check First (use with caution)
open cmd and input diskpart
Now when in Diskpart window
Input below commands
list volume - This will list all your volumes/partitions
select volume n - This will select your volume to resize/extend n will be your volume number
extend size=10240 - you need to input your desired size to be added to selected volume
10240=10GB

Converting a drive letter to a Partition ID / Disk ID

Given a drive letter, how do I get the OSImage InstallTo Partition ID and Disk ID without using the registry?
The WMI class Win32_DiskPartition is what I need. Now to figure out how to use WMI to get this information from a drive letter.
Win32_LogicalDisk is also useful, MSDN Example, and this stackoverflow answer.
Update: Hmm, this doesn't work! Not in the Windows Installer anyway (WMI is missing from Windows PE!!) so I am using the other answer QueryDosDevice (e.g. \\.\PhysicalDisk1\Partition0) and hacking it together. This sucks Microsoft, accept a damn path in your installer.
Answer: IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS works to get the Disk ID. And DeviceIoControl IOCTL_DISK_GET_PARTITION_INFO_EX (thanks TLama) gets me the Partition ID.
Have you tried simply calling QueryDosDevice?

VBScript to get DC SYSVOL information (path, size, free space)

I am obtaining information about my DCs and need to pull in the path to sysvol, total size, and free space remaining.
Cant his be done in VBScript and if so how?
Thanks
Have a look at this Microsoft support page - the registry entries are in this document of where the SYSVOL and other NTDS directories are stored.
You might find that you can also get this information through Active Directory however I'm not sure - I will check ADSIEdit shorly.
You can do it through the WMI. See an example here: http://www.computerperformance.co.uk/vbscript/wmi_disks.htm

How does one map physical sectors of a disk to the files that contain them on an HFS+ volume on Mac OS X

I've been recovering a hard disk using dd_rescue, which provides me a list of all of the device sectors it could not copy due to hardware errors.
I'd like to take that list, and write a tool to give me all of the files that contain these bad sectors so I can delete them. I'm not sure what APIs I can use to do this--essentially i want to get a list of all files on disk and for each file, a list of the ranges of sectors it occupies on disk.
My first guess is that I will iterate over each directory entry on the disk and check to see if the file overlaps one of these bad sectors. Maybe there's a better way.
If you want to map a file's data location to a physical block (sector), you can use the fcntl(2) call with the F_LOG2PHYS command. Not all file systems support this command, but HFS+ does. Just use lseek to pick the file offset and you can get back the diskoffset from F_LOG2PHYS (it's returned in a struct log2phys in the l2p_devoffset field). See fcntl.h for more details.
It's an old question, but since it still is among the top hits when searching the topic, here's to all who searched:
Since Mac OS X 10.6 fsck_hfs(8) can map physical sectors to files (see option -B). A note on usage: matching will only be successful if checking of the catalog was actually performed. So you might have to force checking with options -l or -f.
BTW, hfsdebug as a PPC binary relies on Rosetta and thus will not run on Lion or later.
There's no API exposed for grubbing through HFS+ filesystems, but the source for the filesystem is available from Apple as part of the XNU kernel. Also check out the hfsdebug tool which might help to understand the fs.

Resources