2 * Copyright (C) International Business Machines Corp., 2000-2004
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/quotaops.h>
21 #include "jfs_incore.h"
22 #include "jfs_inode.h"
23 #include "jfs_filsys.h"
25 #include "jfs_dinode.h"
26 #include "jfs_debug.h"
31 * FUNCTION: Allocate a new inode
34 struct inode
*ialloc(struct inode
*parent
, umode_t mode
)
36 struct super_block
*sb
= parent
->i_sb
;
38 struct jfs_inode_info
*jfs_inode
;
41 inode
= new_inode(sb
);
43 jfs_warn("ialloc: new_inode returned NULL!");
47 jfs_inode
= JFS_IP(inode
);
49 rc
= diAlloc(parent
, S_ISDIR(mode
), inode
);
51 jfs_warn("ialloc: diAlloc returned %d!", rc
);
52 make_bad_inode(inode
);
57 inode
->i_uid
= current
->fsuid
;
58 if (parent
->i_mode
& S_ISGID
) {
59 inode
->i_gid
= parent
->i_gid
;
63 inode
->i_gid
= current
->fsgid
;
66 * Allocate inode to quota.
68 if (DQUOT_ALLOC_INODE(inode
)) {
70 inode
->i_flags
|= S_NOQUOTA
;
78 jfs_inode
->mode2
= IDIRECTORY
| mode
;
80 jfs_inode
->mode2
= INLINEEA
| ISPARSE
| mode
;
81 inode
->i_blksize
= sb
->s_blocksize
;
83 inode
->i_mtime
= inode
->i_atime
= inode
->i_ctime
= CURRENT_TIME
;
84 jfs_inode
->otime
= inode
->i_ctime
.tv_sec
;
85 inode
->i_generation
= JFS_SBI(sb
)->gengen
++;
89 /* Zero remaining fields */
90 memset(&jfs_inode
->acl
, 0, sizeof(dxd_t
));
91 memset(&jfs_inode
->ea
, 0, sizeof(dxd_t
));
92 jfs_inode
->next_index
= 0;
93 jfs_inode
->acltype
= 0;
94 jfs_inode
->btorder
= 0;
95 jfs_inode
->btindex
= 0;
96 jfs_inode
->bxflag
= 0;
98 jfs_inode
->atlhead
= 0;
99 jfs_inode
->atltail
= 0;
100 jfs_inode
->xtlid
= 0;
102 jfs_info("ialloc returns inode = 0x%p\n", inode
);