Which role? Host or device?
If as host, the linux kernel source(kernel source/driver/usb/storage)has sample, you can modify it for yourself.
Else if you want to write a mass storage driver as USB device.
You can write a gadget driver in linux platform.
Search gadget in google.