ReactOS 0.4.15-dev-8428-g6910fa6
htree.c File Reference
#include "ext2fs.h"
Include dependency graph for htree.c:

Go to the source code of this file.

Macros

#define NAMEI_RA_CHUNKS   2
 
#define NAMEI_RA_BLOCKS   4
 
#define NAMEI_RA_SIZE   (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)
 
#define NAMEI_RA_INDEX(c, b)   (((c) * NAMEI_RA_BLOCKS) + (b))
 

Functions

__u32 ext3_current_time (struct inode *in)
 
void ext3_warning (struct super_block *sb, const char *function, char *fmt,...)
 
struct buffer_headext3_bread (struct ext2_icb *icb, struct inode *inode, unsigned long block, int *err)
 
struct buffer_headext3_append (struct ext2_icb *icb, struct inode *inode, ext3_lblk_t *block, int *err)
 
void ext3_inc_count (struct inode *inode)
 
void ext3_dec_count (struct inode *inode)
 
unsigned char ext3_type_by_mode (umode_t mode)
 
void ext3_set_de_type (struct super_block *sb, struct ext3_dir_entry_2 *de, umode_t mode)
 
int ext3_mark_inode_dirty (struct ext2_icb *icb, struct inode *in)
 
void ext3_update_dx_flag (struct inode *inode)
 
int add_dirent_to_buf (struct ext2_icb *icb, struct dentry *dentry, struct inode *inode, struct ext3_dir_entry_2 *de, struct buffer_head *bh)
 
int ext3_release_dir (struct inode *inode, struct file *filp)
 
int ext3_add_entry (struct ext2_icb *icb, struct dentry *dentry, struct inode *inode)
 
int ext3_delete_entry (struct ext2_icb *icb, struct inode *dir, struct ext3_dir_entry_2 *de_del, struct buffer_head *bh)
 
int ext3_is_dir_empty (struct ext2_icb *icb, struct inode *inode)
 
static int search_dirblock (struct buffer_head *bh, struct inode *dir, struct dentry *dentry, unsigned long offset, struct ext3_dir_entry_2 **res_dir)
 
struct buffer_headext3_find_entry (struct ext2_icb *icb, struct dentry *dentry, struct ext3_dir_entry_2 **res_dir)
 

Macro Definition Documentation

◆ NAMEI_RA_BLOCKS

#define NAMEI_RA_BLOCKS   4

Definition at line 2151 of file htree.c.

◆ NAMEI_RA_CHUNKS

#define NAMEI_RA_CHUNKS   2

Definition at line 2150 of file htree.c.

◆ NAMEI_RA_INDEX

#define NAMEI_RA_INDEX (   c,
  b 
)    (((c) * NAMEI_RA_BLOCKS) + (b))

Definition at line 2153 of file htree.c.

◆ NAMEI_RA_SIZE

#define NAMEI_RA_SIZE   (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)

Definition at line 2152 of file htree.c.

Function Documentation

◆ add_dirent_to_buf()

int add_dirent_to_buf ( struct ext2_icb icb,
struct dentry dentry,
struct inode inode,
struct ext3_dir_entry_2 de,
struct buffer_head bh 
)

Definition at line 386 of file htree.c.

389{
390 struct inode *dir = dentry->d_parent->d_inode;
391 const char *name = dentry->d_name.name;
392 int namelen = dentry->d_name.len;
393 unsigned int offset = 0;
394 unsigned short reclen;
395 int nlen, rlen, err;
396 char *top;
397
398 reclen = EXT3_DIR_REC_LEN(namelen);
399 if (!de) {
400 de = (struct ext3_dir_entry_2 *)bh->b_data;
401 top = bh->b_data + dir->i_sb->s_blocksize - reclen;
402 while ((char *) de <= top) {
403 if (!ext3_check_dir_entry("ext3_add_entry", dir, de,
404 bh, offset)) {
405 __brelse(bh);
406 return -EIO;
407 }
408 if (ext3_match(namelen, name, de)) {
409 __brelse(bh);
410 return -EEXIST;
411 }
412 nlen = EXT3_DIR_REC_LEN(de->name_len);
414 if ((de->inode? rlen - nlen: rlen) >= reclen)
415 break;
416 de = (struct ext3_dir_entry_2 *)((char *)de + rlen);
417 offset += rlen;
418 }
419 if ((char *) de > top)
420 return -ENOSPC;
421 }
422
423 /* By now the buffer is marked for journaling */
424 nlen = EXT3_DIR_REC_LEN(de->name_len);
426 if (de->inode) {
427 struct ext3_dir_entry_2 *de1 = (struct ext3_dir_entry_2 *)((char *)de + nlen);
428 de1->rec_len = ext3_rec_len_to_disk(rlen - nlen);
429 de->rec_len = ext3_rec_len_to_disk(nlen);
430 de = de1;
431 }
433 if (inode) {
435 ext3_set_de_type(dir->i_sb, de, inode->i_mode);
436 } else
437 de->inode = 0;
438 de->name_len = (__u8)namelen;
439 memcpy(de->name, name, namelen);
440
441 /*
442 * XXX shouldn't update any times until successful
443 * completion of syscall, but too many callers depend
444 * on this.
445 *
446 * XXX similarly, too many callers depend on
447 * ext4_new_inode() setting the times, but error
448 * recovery deletes the inode, so the worst that can
449 * happen is that the times are slightly out of date
450 * and/or different from the directory change time.
451 */
452 dir->i_mtime = dir->i_ctime = ext3_current_time(dir);
454 dir->i_version++;
456 set_buffer_dirty(bh);
457 __brelse(bh);
458 return 0;
459}
#define EEXIST
Definition: acclib.h:88
#define EIO
Definition: acclib.h:81
unsigned int dir
Definition: maze.c:112
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
#define ENOSPC
Definition: errno.h:34
int ext3_check_dir_entry(const char *function, struct inode *dir, struct ext3_dir_entry_2 *de, struct buffer_head *bh, unsigned long offset)
Definition: generic.c:2209
static __le16 ext3_rec_len_to_disk(unsigned len)
Definition: ext3_fs.h:880
#define EXT3_DIR_REC_LEN(len)
Definition: ext3_fs.h:867
#define EXT3_FT_UNKNOWN
Definition: ext3_fs.h:786
static unsigned ext3_rec_len_from_disk(__le16 dlen)
Definition: ext3_fs.h:871
GLint namelen
Definition: glext.h:7232
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLintptr offset
Definition: glext.h:5920
__u32 ext3_current_time(struct inode *in)
Definition: htree.c:204
int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in)
Definition: htree.c:360
void ext3_set_de_type(struct super_block *sb, struct ext3_dir_entry_2 *de, umode_t mode)
Definition: htree.c:347
void ext3_update_dx_flag(struct inode *inode)
Definition: htree.c:368
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define cpu_to_le32
Definition: module.h:148
void __brelse(struct buffer_head *)
Definition: linux.c:808
#define err(...)
#define __u8
Definition: types.h:12
char * b_data
Definition: module.h:735
Definition: fs.h:117
struct dentry::@710 d_name
struct dentry * d_parent
Definition: fs.h:124
Definition: ext3_fs.h:774
char name[EXT3_NAME_LEN]
Definition: ext3_fs.h:779
__le32 inode
Definition: ext3_fs.h:775
__u8 name_len
Definition: ext3_fs.h:777
__le16 rec_len
Definition: ext3_fs.h:776
__u8 file_type
Definition: ext3_fs.h:778
Definition: fs.h:78
__u32 i_ino
Definition: fs.h:79
umode_t i_mode
Definition: fs.h:87
Definition: name.c:39

Referenced by ext3_add_entry().

◆ ext3_add_entry()

int ext3_add_entry ( struct ext2_icb icb,
struct dentry dentry,
struct inode inode 
)

Definition at line 1946 of file htree.c.

1947{
1948 struct inode *dir = dentry->d_parent->d_inode;
1949 struct buffer_head *bh;
1950 struct ext3_dir_entry_2 *de;
1951 struct super_block *sb;
1952 int retval;
1953#ifdef EXT2_HTREE_INDEX
1954 int dx_fallback=0;
1955#endif
1956 unsigned blocksize;
1958
1959 sb = dir->i_sb;
1960 blocksize = sb->s_blocksize;
1961 if (!dentry->d_name.len)
1962 return -EINVAL;
1963
1964#ifdef EXT2_HTREE_INDEX
1965 if (is_dx(dir)) {
1966 retval = ext3_dx_add_entry(icb, dentry, inode);
1967 if (!retval || (retval != ERR_BAD_DX_DIR))
1968 return retval;
1969 EXT3_I(dir)->i_flags &= ~EXT3_INDEX_FL;
1970 dx_fallback++;
1971 ext3_save_inode(icb, dir);
1972 }
1973#endif
1974
1975 blocks = (ext3_lblk_t)(dir->i_size >> sb->s_blocksize_bits);
1976 for (block = 0; block < blocks; block++) {
1977 bh = ext3_bread(icb, dir, block, &retval);
1978 if (!bh)
1979 return retval;
1980 retval = add_dirent_to_buf(icb, dentry, inode, NULL, bh);
1981 if (retval != -ENOSPC)
1982 return retval;
1983
1984#ifdef EXT2_HTREE_INDEX
1985 if (blocks == 1 && !dx_fallback &&
1987 return make_indexed_dir(icb, dentry, inode, bh);
1988#endif
1989
1990 brelse(bh);
1991 }
1992 bh = ext3_append(icb, dir, &block, &retval);
1993 if (!bh)
1994 return retval;
1995 de = (struct ext3_dir_entry_2 *) bh->b_data;
1996 de->inode = 0;
1997 de->rec_len = ext3_rec_len_to_disk(blocksize);
1998 return add_dirent_to_buf(icb, dentry, inode, de, bh);
1999}
#define EINVAL
Definition: acclib.h:90
#define NULL
Definition: types.h:112
superblock * sb
Definition: btrfs.c:4261
#define EXT3_FEATURE_COMPAT_DIR_INDEX
Definition: ext3_fs.h:669
#define EXT3_HAS_COMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:645
#define is_dx(dir)
Definition: ext3_fs.h:901
__u32 ext3_lblk_t
Definition: ext3_fs_i.h:30
struct buffer_head * ext3_bread(struct ext2_icb *icb, struct inode *inode, unsigned long block, int *err)
Definition: htree.c:230
struct buffer_head * ext3_append(struct ext2_icb *icb, struct inode *inode, ext3_lblk_t *block, int *err)
Definition: htree.c:279
int add_dirent_to_buf(struct ext2_icb *icb, struct dentry *dentry, struct inode *inode, struct ext3_dir_entry_2 *de, struct buffer_head *bh)
Definition: htree.c:386
static int blocks
Definition: mkdosfs.c:527
static void brelse(struct buffer_head *bh)
Definition: module.h:955
Definition: fs.h:64
static unsigned int block
Definition: xmlmemory.c:101

Referenced by Ext2AddEntry().

◆ ext3_append()

struct buffer_head * ext3_append ( struct ext2_icb icb,
struct inode inode,
ext3_lblk_t block,
int err 
)

Definition at line 279 of file htree.c.

281{
283 PEXT2_FCB dcb = mcb->Fcb;
285
286 ASSERT(dcb);
287 ASSERT(inode == dcb->Inode);
288
289 /* allocate new block since there's no space for us */
290 *block = (ext3_lblk_t)(inode->i_size >> inode->i_sb->s_blocksize_bits);
291 dcb->Header.AllocationSize.QuadPart += dcb->Vcb->BlockSize;
292 status = Ext2ExpandFile(icb, dcb->Vcb, mcb, &(dcb->Header.AllocationSize));
293 if (NT_SUCCESS(status)) {
294
295 /* update Dcb */
296 dcb->Header.ValidDataLength = dcb->Header.FileSize = dcb->Header.AllocationSize;
297 mcb->Inode.i_size = dcb->Header.AllocationSize.QuadPart;
298
299 /* save parent directory's inode */
300 Ext2SaveInode(icb, dcb->Vcb, inode);
301 }
302
303 return ext3_bread(icb, inode, *block, err);
304}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
BOOLEAN Ext2SaveInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:552
NTSTATUS Ext2ExpandFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER Size)
Definition: fileinfo.c:1152
#define ASSERT(a)
Definition: mode.c:44
struct inode * Inode
Definition: ext2fs.h:866
PEXT2_VCB Vcb
Definition: ext2fs.h:869
PEXT2_FCB Fcb
Definition: ext2fs.h:914
struct inode Inode
Definition: ext2fs.h:945
ULONG BlockSize
Definition: ext2fs.h:728
loff_t i_size
Definition: fs.h:80
struct super_block * i_sb
Definition: fs.h:96
Definition: ps.c:97
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by Ext2AddDotEntries(), and ext3_add_entry().

◆ ext3_bread()

struct buffer_head * ext3_bread ( struct ext2_icb icb,
struct inode inode,
unsigned long  block,
int err 
)

Definition at line 230 of file htree.c.

232{
233 struct buffer_head * bh = NULL;
235 ULONG lbn = 0, num = 0;
236
238
239 /* for symlink file, read it's target instead */
240 if (NULL != Mcb && IsMcbSymLink(Mcb))
241 Mcb = Mcb->Target;
242 if (NULL == Mcb) {
243 *err = -EINVAL;
244 return NULL;
245 }
246
247 /* mapping file offset to ext2 block */
248 if (INODE_HAS_EXTENT(&Mcb->Inode)) {
249 status = Ext2MapExtent(icb, inode->i_sb->s_priv,
250 Mcb, block, FALSE,
251 &lbn, &num);
252 } else {
253 status = Ext2MapIndirect(icb, inode->i_sb->s_priv,
254 Mcb, block, FALSE,
255 &lbn, &num);
256 }
257
258 if (!NT_SUCCESS(status)) {
260 return bh;
261 }
262
263 bh = sb_getblk(inode->i_sb, lbn);
264 if (!bh) {
265 *err = -ENOMEM;
266 return bh;
267 }
268 if (buffer_uptodate(bh))
269 return bh;
270
271 *err = bh_submit_read(bh);
272 if (*err) {
273 __brelse(bh);
274 return NULL;
275 }
276 return bh;
277}
#define ENOMEM
Definition: acclib.h:84
#define FALSE
Definition: types.h:117
#define IsMcbSymLink(Mcb)
Definition: ext2fs.h:962
NTSTATUS Ext2MapExtent(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN Alloc, OUT PULONG Block, OUT PULONG Number)
Definition: extents.c:25
NTSTATUS Ext2MapIndirect(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Index, IN BOOLEAN bAlloc, OUT PULONG pBlock, OUT PULONG Number)
Definition: indirect.c:835
int Ext2LinuxError(NTSTATUS Status)
Definition: misc.c:304
#define INODE_HAS_EXTENT(i)
Definition: ext4_ext.h:228
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:348
GLuint GLuint num
Definition: glext.h:9618
int bh_submit_read(struct buffer_head *bh)
Definition: linux.c:892
static struct buffer_head * sb_getblk(struct super_block *sb, sector_t block)
Definition: module.h:976
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59

Referenced by ext3_add_entry(), ext3_append(), ext3_find_entry(), and ext3_is_dir_empty().

◆ ext3_current_time()

__u32 ext3_current_time ( struct inode in)

Definition at line 204 of file htree.c.

205{
206 LARGE_INTEGER SysTime;
207 KeQuerySystemTime(&SysTime);
208
209 return Ext2LinuxTime(SysTime);
210}
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
ULONG Ext2LinuxTime(IN LARGE_INTEGER SysTime)
Definition: misc.c:51

Referenced by add_dirent_to_buf(), Ext2RemoveEntry(), and Ext2SetFileType().

◆ ext3_dec_count()

void ext3_dec_count ( struct inode inode)

Definition at line 312 of file htree.c.

313{
314 inode->i_nlink--;
315}
__u16 i_nlink
Definition: fs.h:91

Referenced by Ext2RemoveEntry(), Ext2SetFileType(), and Ext2SetReparsePoint().

◆ ext3_delete_entry()

int ext3_delete_entry ( struct ext2_icb icb,
struct inode dir,
struct ext3_dir_entry_2 de_del,
struct buffer_head bh 
)

Definition at line 2005 of file htree.c.

2008{
2009 struct ext3_dir_entry_2 *de, *pde = NULL;
2010 size_t i = 0;
2011
2012 de = (struct ext3_dir_entry_2 *) bh->b_data;
2013 while (i < bh->b_size) {
2014 if (!ext3_check_dir_entry("ext3_delete_entry", dir, de, bh, i))
2015 return -EIO;
2016 if (de == de_del) {
2017 if (pde)
2021 else
2022 de->inode = 0;
2023 dir->i_version++;
2024 /* ext3_journal_dirty_metadata(handle, bh); */
2025 set_buffer_dirty(bh);
2026 return 0;
2027 }
2029 pde = de;
2030 de = ext3_next_entry(de);
2031 }
2032 return -ENOENT;
2033}
#define ENOENT
Definition: acclib.h:79
struct ext3_dir_entry_2 * ext3_next_entry(struct ext3_dir_entry_2 *p)
Definition: generic.c:2244
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by Ext2RemoveEntry().

◆ ext3_find_entry()

struct buffer_head * ext3_find_entry ( struct ext2_icb icb,
struct dentry dentry,
struct ext3_dir_entry_2 **  res_dir 
)

Definition at line 2166 of file htree.c.

2169{
2170 struct inode *dir = dentry->d_parent->d_inode;
2171 struct super_block *sb = dir->i_sb;
2172 struct buffer_head *bh_use[NAMEI_RA_SIZE];
2173 struct buffer_head *bh, *ret = NULL;
2175 int ra_max = 0; /* Number of bh's in the readahead
2176 buffer, bh_use[] */
2177 int ra_ptr = 0; /* Current index into readahead
2178 buffer */
2179 int num = 0;
2180 ext3_lblk_t nblocks;
2181 int i, err;
2182 int namelen = dentry->d_name.len;
2183
2184 *res_dir = NULL;
2185 if (namelen > EXT3_NAME_LEN)
2186 return NULL;
2187
2188#ifdef EXT2_HTREE_INDEX
2189 if (icb->MajorFunction != IRP_MJ_CREATE && is_dx(dir)) {
2190 bh = ext3_dx_find_entry(icb, dentry, res_dir, &err);
2191 /*
2192 * On success, or if the error was file not found,
2193 * return. Otherwise, fall back to doing a search the
2194 * old fashioned way.
2195 */
2196 if (bh || (err != ERR_BAD_DX_DIR))
2197 return bh;
2198 dxtrace(printk("ext4_find_entry: dx failed, "
2199 "falling back\n"));
2200 }
2201#endif
2202
2203 nblocks = (ext3_lblk_t)(dir->i_size >> EXT3_BLOCK_SIZE_BITS(sb));
2204 start = 0;
2205 block = start;
2206restart:
2207 do {
2208 /*
2209 * We deal with the read-ahead logic here.
2210 */
2211 if (ra_ptr >= ra_max) {
2212 /* Refill the readahead buffer */
2213 ra_ptr = 0;
2214 b = block;
2215 for (ra_max = 0; ra_max < NAMEI_RA_SIZE; ra_max++) {
2216 /*
2217 * Terminate if we reach the end of the
2218 * directory and must wrap, or if our
2219 * search has finished at this block.
2220 */
2221 if (b >= nblocks || (num && block == start)) {
2222 bh_use[ra_max] = NULL;
2223 break;
2224 }
2225 num++;
2226 bh = ext3_bread(icb, dir, b++, &err);
2227 bh_use[ra_max] = bh;
2228 }
2229 }
2230 if ((bh = bh_use[ra_ptr++]) == NULL)
2231 goto next;
2232 wait_on_buffer(bh);
2233 if (!buffer_uptodate(bh)) {
2234 /* read error, skip block & hope for the best */
2235 ext3_error(sb, __FUNCTION__, "reading directory #%lu "
2236 "offset %lu", dir->i_ino,
2237 (unsigned long)block);
2238 brelse(bh);
2239 goto next;
2240 }
2241 i = search_dirblock(bh, dir, dentry,
2242 block << EXT3_BLOCK_SIZE_BITS(sb), res_dir);
2243 if (i == 1) {
2244 ret = bh;
2245 goto cleanup_and_exit;
2246 } else {
2247 brelse(bh);
2248 if (i < 0)
2249 goto cleanup_and_exit;
2250 }
2251next:
2252 if (++block >= nblocks)
2253 block = 0;
2254 } while (block != start);
2255
2256 /*
2257 * If the directory has grown while we were searching, then
2258 * search the last part of the directory before giving up.
2259 */
2260 block = nblocks;
2261 nblocks = (ext3_lblk_t)(dir->i_size >> EXT3_BLOCK_SIZE_BITS(sb));
2262 if (block < nblocks) {
2263 start = 0;
2264 goto restart;
2265 }
2266
2267cleanup_and_exit:
2268 /* Clean up the read-ahead blocks */
2269 for (; ra_ptr < ra_max; ra_ptr++)
2270 brelse(bh_use[ra_ptr]);
2271 return ret;
2272}
void restart(int argc, const char *argv[])
Definition: cmds.c:2115
#define __FUNCTION__
Definition: types.h:116
struct buffer_head * ext3_dx_find_entry(struct ext2_icb *, struct dentry *dentry, struct ext3_dir_entry_2 **res_dir, int *err)
#define ext3_error
Definition: ext2fs.h:2593
#define EXT3_NAME_LEN
Definition: ext3_fs.h:759
#define EXT3_BLOCK_SIZE_BITS(s)
Definition: ext3_fs.h:87
GLuint start
Definition: gl.h:1545
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define NAMEI_RA_SIZE
Definition: htree.c:2152
static int search_dirblock(struct buffer_head *bh, struct inode *dir, struct dentry *dentry, unsigned long offset, struct ext3_dir_entry_2 **res_dir)
Definition: htree.c:2109
#define b
Definition: ke_i.h:79
#define printk
Definition: module.h:231
static void wait_on_buffer(struct buffer_head *bh)
Definition: module.h:1021
static unsigned __int64 next
Definition: rand_nt.c:6
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
UCHAR MajorFunction
Definition: ext2fs.h:1056
int ret

Referenced by Ext2RemoveEntry(), Ext2ScanDir(), and Ext2SetFileType().

◆ ext3_inc_count()

void ext3_inc_count ( struct inode inode)

Definition at line 307 of file htree.c.

308{
309 inode->i_nlink++;
310}

Referenced by Ext2AddEntry(), and Ext2SetFileType().

◆ ext3_is_dir_empty()

int ext3_is_dir_empty ( struct ext2_icb icb,
struct inode inode 
)

Definition at line 2038 of file htree.c.

2039{
2040 unsigned int offset;
2041 struct buffer_head *bh;
2042 struct ext3_dir_entry_2 *de, *de1;
2043 struct super_block *sb;
2044 int err = 0;
2045
2046 sb = inode->i_sb;
2048 !(bh = ext3_bread(icb, inode, 0, &err))) {
2049 if (err)
2051 "error %d reading directory #%lu offset 0",
2052 err, inode->i_ino);
2053 else
2055 "bad directory (dir #%lu) - no data block",
2056 inode->i_ino);
2057 return 1;
2058 }
2059 de = (struct ext3_dir_entry_2 *) bh->b_data;
2060 de1 = ext3_next_entry(de);
2061 if (le32_to_cpu(de->inode) != inode->i_ino ||
2062 !le32_to_cpu(de1->inode) ||
2063 strcmp(".", de->name) ||
2064 strcmp("..", de1->name)) {
2065 ext3_warning(inode->i_sb, "empty_dir",
2066 "bad directory (dir #%lu) - no `.' or `..'",
2067 inode->i_ino);
2068 brelse(bh);
2069 return 1;
2070 }
2073 de = ext3_next_entry(de1);
2074 while (offset < inode->i_size) {
2075 if (!bh ||
2076 (void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {
2077 err = 0;
2078 brelse(bh);
2080 if (!bh) {
2081 if (err)
2082 ext3_error(sb, __FUNCTION__, "error %d reading directory"
2083 " #%lu offset %u", err, inode->i_ino, offset);
2084 offset += sb->s_blocksize;
2085 continue;
2086 }
2087 de = (struct ext3_dir_entry_2 *) bh->b_data;
2088 }
2089 if (!ext3_check_dir_entry("empty_dir", inode, de, bh, offset)) {
2090 de = (struct ext3_dir_entry_2 *)(bh->b_data +
2091 sb->s_blocksize);
2092 offset = (offset | (sb->s_blocksize - 1)) + 1;
2093 continue;
2094 }
2095 if (le32_to_cpu(de->inode)) {
2096 brelse(bh);
2097 return 0;
2098 }
2100 de = ext3_next_entry(de);
2101 }
2102 brelse(bh);
2103 return 1;
2104}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void ext3_warning(struct super_block *sb, const char *function, char *fmt,...)
Definition: htree.c:212
#define le32_to_cpu
Definition: module.h:149

Referenced by Ext2IsDirectoryEmpty().

◆ ext3_mark_inode_dirty()

int ext3_mark_inode_dirty ( struct ext2_icb icb,
struct inode in 
)

Definition at line 360 of file htree.c.

361{
362 if (Ext2SaveInode(icb, in->i_sb->s_priv, in))
363 return 0;
364
365 return -ENOMEM;
366}
GLuint in
Definition: glext.h:9616

Referenced by add_dirent_to_buf(), Ext2AddDotEntries(), Ext2AddEntry(), Ext2RemoveEntry(), and Ext2SetFileType().

◆ ext3_release_dir()

int ext3_release_dir ( struct inode inode,
struct file filp 
)

Definition at line 1929 of file htree.c.

1930{
1931 return 0;
1932}

Referenced by Ext2Cleanup().

◆ ext3_set_de_type()

void ext3_set_de_type ( struct super_block sb,
struct ext3_dir_entry_2 de,
umode_t  mode 
)

Definition at line 347 of file htree.c.

350{
353}
#define EXT3_FEATURE_INCOMPAT_FILETYPE
Definition: ext3_fs.h:679
#define EXT3_HAS_INCOMPAT_FEATURE(sb, mask)
Definition: ext3_fs.h:649
GLenum mode
Definition: glext.h:6217
unsigned char ext3_type_by_mode(umode_t mode)
Definition: htree.c:317

Referenced by add_dirent_to_buf(), Ext2AddDotEntries(), and Ext2SetFileType().

◆ ext3_type_by_mode()

unsigned char ext3_type_by_mode ( umode_t  mode)

Definition at line 317 of file htree.c.

318{
319 unsigned char type = 0;
320
321 switch (mode & S_IFMT) {
322 case S_IFREG:
324 break;
325 case S_IFDIR:
327 break;
328 case S_IFCHR:
330 break;
331 case S_IFBLK:
333 break;
334 case S_IFIFO:
336 break;
337 case S_IFSOCK:
339 break;
340 case S_IFLNK:
342 }
343
344 return type;
345};
#define S_IFDIR
Definition: acwin.h:115
#define S_IFREG
Definition: ext2fs.h:361
#define S_IFSOCK
Definition: ext2fs.h:359
#define S_IFIFO
Definition: ext2fs.h:365
#define S_IFBLK
Definition: ext2fs.h:362
#define S_IFMT
Definition: ext2fs.h:358
#define S_IFCHR
Definition: ext2fs.h:364
#define S_IFLNK
Definition: ext2fs.h:360
#define EXT3_FT_FIFO
Definition: ext3_fs.h:791
#define EXT3_FT_SOCK
Definition: ext3_fs.h:792
#define EXT3_FT_DIR
Definition: ext3_fs.h:788
#define EXT3_FT_BLKDEV
Definition: ext3_fs.h:790
#define EXT3_FT_REG_FILE
Definition: ext3_fs.h:787
#define EXT3_FT_SYMLINK
Definition: ext3_fs.h:793
#define EXT3_FT_CHRDEV
Definition: ext3_fs.h:789
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by ext3_set_de_type().

◆ ext3_update_dx_flag()

void ext3_update_dx_flag ( struct inode inode)

Definition at line 368 of file htree.c.

369{
372 EXT3_I(inode)->i_flags &= ~EXT3_INDEX_FL;
373}

Referenced by add_dirent_to_buf(), and Ext2RemoveEntry().

◆ ext3_warning()

void ext3_warning ( struct super_block sb,
const char function,
char fmt,
  ... 
)

Definition at line 212 of file htree.c.

214{
215#if DX_DEBUG
217
218 va_start(args, fmt);
219 printk("EXT3-fs warning (device %s): %s: ",
220 sb->s_id, function);
221 printk(fmt, args);
222 printk("\n");
223 va_end(args);
224#endif
225}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66
Definition: match.c:390
Definition: dsound.c:943

Referenced by Ext2RemoveEntry(), and ext3_is_dir_empty().

◆ search_dirblock()

static int search_dirblock ( struct buffer_head bh,
struct inode dir,
struct dentry dentry,
unsigned long  offset,
struct ext3_dir_entry_2 **  res_dir 
)
inlinestatic

Definition at line 2109 of file htree.c.

2114{
2115 struct ext3_dir_entry_2 * de;
2116 char * dlimit;
2117 int de_len;
2118 const char *name = dentry->d_name.name;
2119 int namelen = dentry->d_name.len;
2120
2121 de = (struct ext3_dir_entry_2 *) bh->b_data;
2122 dlimit = bh->b_data + dir->i_sb->s_blocksize;
2123 while ((char *) de < dlimit) {
2124 /* this code is executed quadratically often */
2125 /* do minimal checking `by hand' */
2126
2127 if ((char *) de + namelen <= dlimit &&
2128 ext3_match (namelen, name, de)) {
2129 /* found a match - just to be sure, do a full check */
2130 if (!ext3_check_dir_entry("ext3_find_entry",
2131 dir, de, bh, offset))
2132 return -1;
2133 *res_dir = de;
2134 return 1;
2135 }
2136 /* prevent looping on a bad block */
2137 de_len = ext3_rec_len_from_disk(de->rec_len);
2138
2139 if (de_len <= 0)
2140 return -1;
2141 offset += de_len;
2142 de = (struct ext3_dir_entry_2 *) ((char *) de + de_len);
2143 }
2144 return 0;
2145}

Referenced by ext3_find_entry().