2 * device.c - Low level device io functions. Part of the Linux-NTFS project.
4 * Copyright (c) 2003 Anton Altaparmakov
6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program/include file is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program (in the main directory of the Linux-NTFS
18 * distribution in the file COPYING); if not, write to the Free Software
19 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 * ntfs_device_alloc - allocate an ntfs device structure and pre-initialize it
32 * name: name of the device (must be present)
33 * state: initial device state (usually zero)
34 * dops: ntfs device operations to use with the device (must be present)
35 * private: pointer to private data (optional)
37 * Allocate an ntfs device structure and pre-initialize it with the user-
38 * specified device operations @dops, device state @state, device name @name,
39 * and optional private data @private.
41 * Note, @name is copied and can hence be freed after this functions returns.
43 * On success return a pointer to the allocated ntfs device structure and on
44 * error return NULL with errno set to the error code returned by malloc().
46 struct ntfs_device *ntfs_device_alloc(const char *name, const long state,
47 struct ntfs_device_operations *dops, void *private)
49 struct ntfs_device *dev;
56 dev = (struct ntfs_device *)malloc(sizeof(struct ntfs_device));
58 if (!(dev->d_name = strdup(name))) {
66 dev->d_private = private;
72 * ntfs_device_free - free an ntfs device structure
73 * @dev: ntfs device structure to free
75 * Free the ntfs device structure @dev.
77 * Return 0 on success or -1 on error with errno set to the error code. The
78 * following error codes are defined:
79 * EINVAL Invalid pointer @dev.
80 * EBUSY Device is still open. Close it before freeing it!
82 int ntfs_device_free(struct ntfs_device *dev)