dir.h revision 9663:ace9a2ac3683
1/* 2 * dir.h - Exports for directory handling. Part of the Linux-NTFS project. 3 * 4 * Copyright (c) 2002 Anton Altaparmakov 5 * Copyright (c) 2005-2006 Yura Pakhuchiy 6 * Copyright (c) 2004-2005 Richard Russon 7 * 8 * This program/include file is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License as published 10 * by the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program/include file is distributed in the hope that it will be 14 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program (in the main directory of the Linux-NTFS 20 * distribution in the file COPYING); if not, write to the Free Software 21 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 */ 23 24#ifndef _NTFS_DIR_H 25#define _NTFS_DIR_H 26 27#include "types.h" 28 29#define PATH_SEP '/' 30 31#ifndef MAX_PATH 32#define MAX_PATH 1024 33#endif 34 35/* 36 * We do not have these under DJGPP, so define our version that do not conflict 37 * with other S_IFs defined under DJGPP. 38 */ 39#ifdef DJGPP 40#ifndef S_IFLNK 41#define S_IFLNK 0120000 42#endif 43#ifndef S_ISLNK 44#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) 45#endif 46#ifndef S_IFSOCK 47#define S_IFSOCK 0140000 48#endif 49#ifndef S_ISSOCK 50#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 51#endif 52#endif 53 54/* 55 * The little endian Unicode strings $I30, $SII, $SDH, $O, $Q, $R 56 * as a global constant. 57 */ 58extern ntfschar NTFS_INDEX_I30[5]; 59extern ntfschar NTFS_INDEX_SII[5]; 60extern ntfschar NTFS_INDEX_SDH[5]; 61extern ntfschar NTFS_INDEX_O[3]; 62extern ntfschar NTFS_INDEX_Q[3]; 63extern ntfschar NTFS_INDEX_R[3]; 64 65extern u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni, 66 const ntfschar *uname, const int uname_len); 67 68extern u64 ntfs_pathname_to_inode_num(ntfs_volume *vol, ntfs_inode *parent, 69 const char *pathname); 70extern ntfs_inode *ntfs_pathname_to_inode(ntfs_volume *vol, ntfs_inode *parent, 71 const char *pathname); 72 73extern ntfs_inode *ntfs_create(ntfs_inode *dir_ni, ntfschar *name, u8 name_len, 74 dev_t type); 75extern ntfs_inode *ntfs_create_device(ntfs_inode *dir_ni, 76 ntfschar *name, u8 name_len, dev_t type, dev_t dev); 77extern ntfs_inode *ntfs_create_symlink(ntfs_inode *dir_ni, 78 ntfschar *name, u8 name_len, ntfschar *target, u8 target_len); 79 80extern int ntfs_delete(ntfs_inode **pni, ntfs_inode *dir_ni, ntfschar *name, 81 u8 name_len); 82 83extern int ntfs_link(ntfs_inode *ni, ntfs_inode *dir_ni, ntfschar *name, 84 u8 name_len); 85 86/* 87 * File types (adapted from include <linux/fs.h>) 88 */ 89#define NTFS_DT_UNKNOWN 0 90#define NTFS_DT_FIFO 1 91#define NTFS_DT_CHR 2 92#define NTFS_DT_DIR 4 93#define NTFS_DT_BLK 6 94#define NTFS_DT_REG 8 95#define NTFS_DT_LNK 10 96#define NTFS_DT_SOCK 12 97#define NTFS_DT_WHT 14 98 99/* 100 * This is the "ntfs_filldir" function type, used by ntfs_readdir() to let 101 * the caller specify what kind of dirent layout it wants to have. 102 * This allows the caller to read directories into their application or 103 * to have different dirent layouts depending on the binary type. 104 */ 105typedef int (*ntfs_filldir_t)(void *dirent, const ntfschar *name, 106 const int name_len, const int name_type, const s64 pos, 107 const MFT_REF mref, const unsigned dt_type); 108 109extern int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos, 110 void *dirent, ntfs_filldir_t filldir); 111 112#endif /* defined _NTFS_DIR_H */ 113