Lines Matching full:dev
67 #define DEV_FD(dev) (*(int *)dev->d_private) argument
110 * @dev:
117 static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags) in ntfs_device_unix_io_open() argument
123 if (NDevOpen(dev)) { in ntfs_device_unix_io_open()
127 if (stat(dev->d_name, &sbuf)) { in ntfs_device_unix_io_open()
128 ntfs_log_perror("Failed to access '%s'", dev->d_name); in ntfs_device_unix_io_open()
132 NDevSetBlock(dev); in ntfs_device_unix_io_open()
134 dev->d_private = ntfs_malloc(sizeof(int)); in ntfs_device_unix_io_open()
135 if (!dev->d_private) in ntfs_device_unix_io_open()
141 if (!NDevBlock(dev) && (flags & O_RDWR) == O_RDWR) in ntfs_device_unix_io_open()
143 *(int*)dev->d_private = open(dev->d_name, flags); in ntfs_device_unix_io_open()
144 if (*(int*)dev->d_private == -1) { in ntfs_device_unix_io_open()
153 if (NDevBlock(dev) && ((flags & O_RDWR) == O_RDWR)) { in ntfs_device_unix_io_open()
157 r = ioctl(DEV_FD(dev), BLKROGET, &state); in ntfs_device_unix_io_open()
160 if (close(DEV_FD(dev))) in ntfs_device_unix_io_open()
168 NDevSetReadOnly(dev); in ntfs_device_unix_io_open()
171 if (NDevReadOnly(dev)) in ntfs_device_unix_io_open()
177 if (fcntl(DEV_FD(dev), F_SETLK, &flk)) { in ntfs_device_unix_io_open()
179 ntfs_log_perror("Failed to %s lock '%s'", NDevReadOnly(dev) ? in ntfs_device_unix_io_open()
180 "read" : "write", dev->d_name); in ntfs_device_unix_io_open()
181 if (close(DEV_FD(dev))) in ntfs_device_unix_io_open()
182 ntfs_log_perror("Failed to close '%s'", dev->d_name); in ntfs_device_unix_io_open()
186 NDevSetOpen(dev); in ntfs_device_unix_io_open()
189 free(dev->d_private); in ntfs_device_unix_io_open()
190 dev->d_private = NULL; in ntfs_device_unix_io_open()
197 * @dev:
203 static int ntfs_device_unix_io_close(struct ntfs_device *dev) in ntfs_device_unix_io_close() argument
207 if (!NDevOpen(dev)) { in ntfs_device_unix_io_close()
209 ntfs_log_perror("Device %s is not open", dev->d_name); in ntfs_device_unix_io_close()
212 if (NDevDirty(dev)) in ntfs_device_unix_io_close()
213 if (ntfs_fsync(DEV_FD(dev))) { in ntfs_device_unix_io_close()
214 ntfs_log_perror("Failed to fsync device %s", dev->d_name); in ntfs_device_unix_io_close()
222 if (fcntl(DEV_FD(dev), F_SETLK, &flk)) in ntfs_device_unix_io_close()
223 ntfs_log_perror("Could not unlock %s", dev->d_name); in ntfs_device_unix_io_close()
224 if (close(DEV_FD(dev))) { in ntfs_device_unix_io_close()
225 ntfs_log_perror("Failed to close device %s", dev->d_name); in ntfs_device_unix_io_close()
228 NDevClearOpen(dev); in ntfs_device_unix_io_close()
229 free(dev->d_private); in ntfs_device_unix_io_close()
230 dev->d_private = NULL; in ntfs_device_unix_io_close()
236 * @dev:
244 static s64 ntfs_device_unix_io_seek(struct ntfs_device *dev, s64 offset, in ntfs_device_unix_io_seek() argument
247 return lseek(DEV_FD(dev), offset, whence); in ntfs_device_unix_io_seek()
252 * @dev:
260 static s64 ntfs_device_unix_io_read(struct ntfs_device *dev, void *buf, in ntfs_device_unix_io_read() argument
263 return read(DEV_FD(dev), buf, count); in ntfs_device_unix_io_read()
268 * @dev:
276 static s64 ntfs_device_unix_io_write(struct ntfs_device *dev, const void *buf, in ntfs_device_unix_io_write() argument
279 if (NDevReadOnly(dev)) { in ntfs_device_unix_io_write()
283 NDevSetDirty(dev); in ntfs_device_unix_io_write()
284 return write(DEV_FD(dev), buf, count); in ntfs_device_unix_io_write()
289 * @dev:
298 static s64 ntfs_device_unix_io_pread(struct ntfs_device *dev, void *buf, in ntfs_device_unix_io_pread() argument
301 return pread(DEV_FD(dev), buf, count, offset); in ntfs_device_unix_io_pread()
306 * @dev:
315 static s64 ntfs_device_unix_io_pwrite(struct ntfs_device *dev, const void *buf, in ntfs_device_unix_io_pwrite() argument
318 if (NDevReadOnly(dev)) { in ntfs_device_unix_io_pwrite()
322 NDevSetDirty(dev); in ntfs_device_unix_io_pwrite()
323 return pwrite(DEV_FD(dev), buf, count, offset); in ntfs_device_unix_io_pwrite()
328 * @dev:
334 static int ntfs_device_unix_io_sync(struct ntfs_device *dev) in ntfs_device_unix_io_sync() argument
338 if (!NDevReadOnly(dev)) { in ntfs_device_unix_io_sync()
339 res = ntfs_fsync(DEV_FD(dev)); in ntfs_device_unix_io_sync()
341 ntfs_log_perror("Failed to sync device %s", dev->d_name); in ntfs_device_unix_io_sync()
343 NDevClearDirty(dev); in ntfs_device_unix_io_sync()
350 * @dev:
357 static int ntfs_device_unix_io_stat(struct ntfs_device *dev, struct stat *buf) in ntfs_device_unix_io_stat() argument
359 return fstat(DEV_FD(dev), buf); in ntfs_device_unix_io_stat()
364 * @dev:
372 static int ntfs_device_unix_io_ioctl(struct ntfs_device *dev, in ntfs_device_unix_io_ioctl() argument
375 return ioctl(DEV_FD(dev), request, argp); in ntfs_device_unix_io_ioctl()