In a C program, how can I tell the linux kernel to TRIM a block on an SSD? I suppose I need a open()device and fcntl()something, but what? It must be shared (i.e. work with different SSDs)
open()
fcntl()
Note: on the device there is no ext4 file system, but only raw data.
You would send it IOCATADELETE. Something like that:
IOCATADELETE
//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);