Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv10451/libntfs
Modified Files:
Makefile.am Makefile.in
Added Files:
inode.c
Log Message:
Add foundation of new inode API.
--- NEW FILE ---
/*
* $Id: inode.c,v 1.1 2002/04/19 18:23:56 antona Exp $
*
* inode.c - Inode handling code. Part of the Linux-NTFS project.
*
* Copyright (c) 2002 Anton Altaparmakov.
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS
* distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdlib.h>
#include <errno.h>
#include "types.h"
#include "endians.h"
#include "inode.h"
#include "debug.h"
#include "mft.h"
static __inline__ ntfs_inode *__allocate_ntfs_inode(ntfs_volume *vol)
{
ntfs_inode *ni;
ni = (ntfs_inode*)calloc(1, sizeof(ntfs_inode));
if (ni)
ni->vol = vol;
return ni;
}
static __inline__ int __release_ntfs_inode(ntfs_inode *ni)
{
// TODO: This needs to be replaced with a flush to disk attempt.
if (NInoDirty(ni) || NInoAttrListDirty(ni)) {
errno = EBUSY;
return -1;
}
if (NInoAttrList(ni) && ni->attr_list)
free(ni->attr_list);
if (NInoAttrListNonResident(ni) && ni->attr_list_rl)
free(ni->attr_list_rl);
if (ni->mft_rec)
free(ni->mft_rec);
free(ni);
return 0;
}
/**
* ntfs_open_inode - open an inode ready for access
* @vol: volume to get the inode from
* @mref: inode number / mft record number to open
*
* Allocate an ntfs_inode structure and initialize it for the given inode
* specified by @mref. @mref specifies the inode number / mft record to read,
* including the sequence number, which can be 0 if no sequence number checking
* is to be performed.
*
* Then, allocate a buffer for the mft record, read the mft record from the
* volume @vol, and attach it to the ntfs_inode structure (->mft_rec).
*
* Also, mst deprotect and sanity check for validity the mft record and abort
* if deprotection or checks fail.
*
* Finally, search for an attribute list attribute in the mft record and if one
* is found, load the attribute list attribute value and attach it to the
* ntfs_inode structure (->attr_list). Also set the NI_AttrList bit to indicate
* this as well as the NI_AttrListNonResident bit if the the attribute list is
* non-resident. In that case, also attach the decompressed run list to the
* ntfs_inode structure (->attr_list_rl).
*
* Return the ntfs_inode structure on success or NULL on error, with errno set
* to the error code.
*/
ntfs_inode *ntfs_open_inode(const ntfs_volume *vol, const MFT_REF mref)
{
ntfs_inode *ni;
if (!vol) {
errno = EINVAL;
return NULL;
}
ni = NULL;
errno = ENOTSUP;
return ni;
}
/**
* ntfs_close_inode - close an ntfs inode and free all associated memory
* @ni: ntfs inode to close
*
* Make sure the ntfs inode @ni is clean, deallocate all memory attached to it,
* and finally free the ntfs inode structure itself.
*
* Return 0 on success or -1 on error with errno set to the error code. On
* error, @ni has not been freed. The user should attempt to handle the error
* and call ntfs_close_inode() again. The following error codes are defined:
*
* EBUSY @ni is dirty and/or the run list is dirty
*/
int ntfs_close_inode(ntfs_inode *ni)
{
return __release_ntfs_inode(ni);
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -U2 -r1.11 -r1.12
--- Makefile.am 15 Apr 2002 20:04:26 -0000 1.11
+++ Makefile.am 19 Apr 2002 18:23:56 -0000 1.12
@@ -26,5 +26,6 @@
disk_io.c \
mst.c \
- unistr.c
+ unistr.c \
+ inode.c
INCLUDES = $(linux_ntfsincludedir) $(all_includes)
Index: Makefile.in
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/Makefile.in,v
retrieving revision 1.15
retrieving revision 1.16
diff -U2 -r1.15 -r1.16
--- Makefile.in 15 Apr 2002 20:04:26 -0000 1.15
+++ Makefile.in 19 Apr 2002 18:23:56 -0000 1.16
@@ -110,5 +110,6 @@
disk_io.c \
mst.c \
- unistr.c
+ unistr.c \
+ inode.c
@@ -124,5 +125,5 @@
libntfs_la_LIBADD =
libntfs_la_OBJECTS = attrib.lo bootsect.lo mft.lo volume.lo disk_io.lo \
-mst.lo unistr.lo
+mst.lo unistr.lo inode.lo
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -136,6 +137,6 @@
TAR = gtar
GZIP_ENV = --best
-DEP_FILES = .deps/attrib.P .deps/bootsect.P .deps/disk_io.P .deps/mft.P \
-.deps/mst.P .deps/unistr.P .deps/volume.P
+DEP_FILES = .deps/attrib.P .deps/bootsect.P .deps/disk_io.P \
+.deps/inode.P .deps/mft.P .deps/mst.P .deps/unistr.P .deps/volume.P
SOURCES = $(libntfs_la_SOURCES)
OBJECTS = $(libntfs_la_OBJECTS)
|