1
/* -*- mode: c; c-basic-offset: 8; -*-
2
* vim: noexpandtab sw=8 ts=8 sts=0:
6
* Create a new directory block
8
* Copyright (C) 2004 Oracle. All rights reserved.
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU General Public
12
* License, version 2, as published by the Free Software Foundation.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* General Public License for more details.
19
* You should have received a copy of the GNU General Public
20
* License along with this program; if not, write to the
21
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
* Boston, MA 021110-1307, USA.
24
* This code is a port of e2fsprogs/lib/ext2fs/newdir.c
25
* Copyright (C) 1994, 1995 Theodore Ts'o.
28
#define _XOPEN_SOURCE 600 /* Triggers magic in features.h */
29
#define _LARGEFILE64_SOURCE
40
* Create new directory block
42
errcode_t ocfs2_new_dir_block(ocfs2_filesys *fs, uint64_t dir_ino,
43
uint64_t parent_ino, char **block)
45
struct ocfs2_dir_entry *dir;
49
ret = ocfs2_malloc_block(fs->fs_io, &buf);
53
memset(buf, 0, fs->fs_blocksize);
55
dir = (struct ocfs2_dir_entry *) buf;
56
dir->rec_len = fs->fs_blocksize;
60
* Set up entry for '.'
63
dir->rec_len = OCFS2_DIR_REC_LEN(1);
65
dir->file_type = OCFS2_FT_DIR;
69
* Set up entry for '..'
71
dir = (struct ocfs2_dir_entry *) (buf + dir->rec_len);
72
dir->inode = parent_ino;
73
dir->rec_len = fs->fs_blocksize - OCFS2_DIR_REC_LEN(1);
75
dir->file_type = OCFS2_FT_DIR;