xref: /haiku/src/add-ons/kernel/file_systems/ntfs/libntfs/dir.h (revision 1acbe440b8dd798953bec31d18ee589aa3f71b73)
1 /*
2  * dir.h - Exports for directory handling. Originated from 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 NTFS-3G
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 S_IFSOCK under BeOS/Haiku
37  */
38 #if defined(__BEOS__) || defined(__HAIKU__)
39 #ifndef S_IFSOCK
40 #define S_IFSOCK 0140000
41 #endif
42 #endif
43 /*
44  * We do not have these under DJGPP, so define our version that do not conflict
45  * with other S_IFs defined under DJGPP.
46  */
47 #ifdef DJGPP
48 #ifndef S_IFLNK
49 #define S_IFLNK  0120000
50 #endif
51 #ifndef S_ISLNK
52 #define S_ISLNK(m)  (((m) & S_IFMT) == S_IFLNK)
53 #endif
54 #ifndef S_IFSOCK
55 #define S_IFSOCK 0140000
56 #endif
57 #ifndef S_ISSOCK
58 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
59 #endif
60 #endif
61 
62 /*
63  * The little endian Unicode strings $I30, $SII, $SDH, $O, $Q, $R
64  * as a global constant.
65  */
66 extern ntfschar NTFS_INDEX_I30[5];
67 extern ntfschar NTFS_INDEX_SII[5];
68 extern ntfschar NTFS_INDEX_SDH[5];
69 extern ntfschar NTFS_INDEX_O[3];
70 extern ntfschar NTFS_INDEX_Q[3];
71 extern ntfschar NTFS_INDEX_R[3];
72 
73 extern u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
74 		const ntfschar *uname, const int uname_len);
75 
76 extern ntfs_inode *ntfs_pathname_to_inode(ntfs_volume *vol, ntfs_inode *parent,
77 		const char *pathname);
78 
79 extern ntfs_inode *ntfs_create(ntfs_inode *dir_ni, ntfschar *name, u8 name_len,
80 		dev_t type);
81 extern ntfs_inode *ntfs_create_device(ntfs_inode *dir_ni,
82 		ntfschar *name, u8 name_len, dev_t type, dev_t dev);
83 extern ntfs_inode *ntfs_create_symlink(ntfs_inode *dir_ni,
84 		ntfschar *name, u8 name_len, ntfschar *target, u8 target_len);
85 extern int ntfs_check_empty_dir(ntfs_inode *ni);
86 extern int ntfs_delete(ntfs_inode *ni, ntfs_inode *dir_ni, ntfschar *name,
87 		u8 name_len);
88 
89 extern int ntfs_link(ntfs_inode *ni, ntfs_inode *dir_ni, ntfschar *name,
90 		u8 name_len);
91 
92 /*
93  * File types (adapted from include <linux/fs.h>)
94  */
95 #define NTFS_DT_UNKNOWN		0
96 #define NTFS_DT_FIFO		1
97 #define NTFS_DT_CHR		2
98 #define NTFS_DT_DIR		4
99 #define NTFS_DT_BLK		6
100 #define NTFS_DT_REG		8
101 #define NTFS_DT_LNK		10
102 #define NTFS_DT_SOCK		12
103 #define NTFS_DT_WHT		14
104 
105 /*
106  * This is the "ntfs_filldir" function type, used by ntfs_readdir() to let
107  * the caller specify what kind of dirent layout it wants to have.
108  * This allows the caller to read directories into their application or
109  * to have different dirent layouts depending on the binary type.
110  */
111 typedef int (*ntfs_filldir_t)(void *dirent, const ntfschar *name,
112 		const int name_len, const int name_type, const s64 pos,
113 		const MFT_REF mref, const unsigned dt_type);
114 
115 extern int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
116 		void *dirent, ntfs_filldir_t filldir);
117 
118 #endif /* defined _NTFS_DIR_H */
119 
120