In a C program, how do I tell the linux kernel to TRIM a block on a SSD disk?
I suppose I have to open()
the device and fcntl()
it something, but what?
It needs to be generic (i.e. work with different SSD disks)
Note: there is no ext4 filesystem on the device, just raw data.
You would send it IOCATADELETE
. Something like this:
//header - may already be defined
#define IOCATADELETE _IOW('a', 104, off_t[2])
//code
int fd = open("/dev/abc", O_RDWR | O_DIRECT);
off_t ioarg[2];
ioarg[0] = 0; //block number
ioarg[1] = 0; //size
ioctl(fd, IOCATADELETE, ioarg);
close(fd);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With