xfs_qcnt_t rc = 0;
xfs_dqid_t dqprid;
int v = 0;
+ mode_t mode;
static char okfmts[] = {
0, /* type 0 unused */
1 << XFS_DINODE_FMT_DEV, /* FIFO */
be32_to_cpu(dip->di_nlink), ino);
error++;
}
- if (xino.i_d.di_mode != 0) {
+ if (dip->di_mode != 0) {
if (v)
dbprintf(_("bad mode %#o for free inode %lld\n"),
- xino.i_d.di_mode, ino);
+ be16_to_cpu(dip->di_mode), ino);
error++;
}
return;
/*
* di_mode is a 16-bit uint so no need to check the < 0 case
*/
- if ((((xino.i_d.di_mode & S_IFMT) >> 12) > 15) ||
- (!(okfmts[(xino.i_d.di_mode & S_IFMT) >> 12] & (1 << xino.i_d.di_format)))) {
+ mode = be16_to_cpu(dip->di_mode);
+ if ((((mode & S_IFMT) >> 12) > 15) ||
+ (!(okfmts[(mode & S_IFMT) >> 12] & (1 << xino.i_d.di_format)))) {
if (v)
dbprintf(_("bad format %d for inode %lld type %#o\n"),
- xino.i_d.di_format, id->ino, xino.i_d.di_mode & S_IFMT);
+ xino.i_d.di_format, id->ino, mode & S_IFMT);
error++;
return;
}
dbprintf(_("inode %lld mode %#o fmt %s "
"afmt %s "
"nex %d anex %d nblk %lld sz %lld%s%s%s%s%s%s%s\n"),
- id->ino, xino.i_d.di_mode, fmtnames[(int)xino.i_d.di_format],
+ id->ino, mode, fmtnames[(int)xino.i_d.di_format],
fmtnames[(int)xino.i_d.di_aformat],
xino.i_d.di_nextents,
xino.i_d.di_anextents,
xino.i_d.di_flags & XFS_DIFLAG_NOATIME ? " noa" : "",
xino.i_d.di_flags & XFS_DIFLAG_NODUMP ? " nod" : "");
security = 0;
- switch (xino.i_d.di_mode & S_IFMT) {
+ switch (mode & S_IFMT) {
case S_IFDIR:
type = DBM_DIR;
if (xino.i_d.di_format == XFS_DINODE_FMT_LOCAL)
}
else
type = DBM_DATA;
- if (xino.i_d.di_mode & (S_ISUID | S_ISGID))
+ if (mode & (S_ISUID | S_ISGID))
security = 1;
break;
case S_IFLNK:
* metadata.
*/
struct inode {
+ mode_t i_mode;
uint32_t i_nlink;
uint32_t i_generation;
uint64_t i_version;
return &ip->i_vnode;
}
+/*
+ * wrappers around the mode checks to simplify code
+ */
+static inline bool XFS_ISREG(struct xfs_inode *ip)
+{
+ return S_ISREG(VFS_I(ip)->i_mode);
+}
+
+static inline bool XFS_ISDIR(struct xfs_inode *ip)
+{
+ return S_ISDIR(VFS_I(ip)->i_mode);
+}
+
/*
* For regular files we only update the on-disk filesize when actually
* writing data back to disk. Until then only the copy in the VFS inode
*/
static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
{
- if (S_ISREG(ip->i_d.di_mode))
+ if (XFS_ISREG(ip))
return ip->i_size;
return ip->i_d.di_size;
}
/*
* set up the inode ops structure that the libxfs code relies on
*/
- if (S_ISDIR(ip->i_d.di_mode))
+ if (XFS_ISDIR(ip))
ip->d_ops = mp->m_dir_inode_ops;
else
ip->d_ops = mp->m_nondir_inode_ops;
static void
libxfs_idestroy(xfs_inode_t *ip)
{
- switch (ip->i_d.di_mode & S_IFMT) {
+ switch (VFS_I(ip)->i_mode & S_IFMT) {
case S_IFREG:
case S_IFDIR:
case S_IFLNK:
return error;
ASSERT(ip != NULL);
- ip->i_d.di_mode = (__uint16_t)mode;
+ VFS_I(ip)->i_mode = mode;
set_nlink(VFS_I(ip), nlink);
ip->i_d.di_uid = cr->cr_uid;
ip->i_d.di_gid = cr->cr_gid;
*/
}
- if (pip && (pip->i_d.di_mode & S_ISGID)) {
+ if (pip && (VFS_I(pip)->i_mode & S_ISGID)) {
ip->i_d.di_gid = pip->i_d.di_gid;
- if ((pip->i_d.di_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR)
- ip->i_d.di_mode |= S_ISGID;
+ if ((VFS_I(pip)->i_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR)
+ VFS_I(ip)->i_mode |= S_ISGID;
}
ip->i_d.di_size = 0;
/*
* set up the inode ops structure that the libxfs code relies on
*/
- if (S_ISDIR(ip->i_d.di_mode))
+ if (XFS_ISDIR(ip))
ip->d_ops = ip->i_mount->m_dir_inode_ops;
else
ip->d_ops = ip->i_mount->m_nondir_inode_ops;
dip = &ip->i_d;
printf("\nOn disk portion\n");
- printf(" di_mode %o\n", dip->di_mode);
+ printf(" di_mode %o\n", VFS_I(ip)->i_mode);
printf(" di_version %x\n", (uint)dip->di_version);
switch (ip->i_d.di_format) {
case XFS_DINODE_FMT_LOCAL:
dip = xfs_buf_offset(bp, ip->i_imap.im_boffset);
ASSERT(ip->i_d.di_magic == XFS_DINODE_MAGIC);
- if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) {
+ if (XFS_ISREG(ip)) {
ASSERT( (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS) ||
(ip->i_d.di_format == XFS_DINODE_FMT_BTREE) );
- }
- else if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
+ } else if (XFS_ISDIR(ip) == S_IFDIR) {
ASSERT( (ip->i_d.di_format == XFS_DINODE_FMT_EXTENTS) ||
(ip->i_d.di_format == XFS_DINODE_FMT_BTREE) ||
(ip->i_d.di_format == XFS_DINODE_FMT_LOCAL) );
* We don't want to deal with the case of keeping inode data inline yet.
* So sending the data fork of a regular inode is invalid.
*/
- ASSERT(!(S_ISREG(ip->i_d.di_mode) && whichfork == XFS_DATA_FORK));
+ ASSERT(!(S_ISREG(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK));
ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL);
if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip))
return 0;
- if (S_ISDIR(ip->i_d.di_mode)) {
+ if (S_ISDIR(VFS_I(ip)->i_mode)) {
memset(&dargs, 0, sizeof(dargs));
dargs.geo = ip->i_mount->m_dir_geo;
dargs.dp = ip;
return xfs_dir2_sf_to_block(&dargs);
}
- if (S_ISLNK(ip->i_d.di_mode))
+ if (S_ISLNK(VFS_I(ip)->i_mode))
return xfs_bmap_local_to_extents(tp, ip, firstblock, 1,
flags, XFS_DATA_FORK,
xfs_symlink_local_to_remote);
{
xfs_dir2_sf_hdr_t *sfp;
- ASSERT(S_ISDIR(dp->i_d.di_mode));
+ ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
if (dp->i_d.di_size == 0) /* might happen during shutdown. */
return 1;
if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
struct xfs_da_args *args;
int error;
- ASSERT(S_ISDIR(dp->i_d.di_mode));
+ ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino);
if (error)
return error;
int rval;
int v; /* type-checking value */
- ASSERT(S_ISDIR(dp->i_d.di_mode));
+ ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
if (inum) {
rval = xfs_dir_ino_validate(tp->t_mountp, inum);
if (rval)
int v; /* type-checking value */
int lock_mode;
- ASSERT(S_ISDIR(dp->i_d.di_mode));
+ ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_lookup);
/*
int rval;
int v; /* type-checking value */
- ASSERT(S_ISDIR(dp->i_d.di_mode));
+ ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_remove);
args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
int rval;
int v; /* type-checking value */
- ASSERT(S_ISDIR(dp->i_d.di_mode));
+ ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
rval = xfs_dir_ino_validate(tp->t_mountp, inum);
if (rval)
struct xfs_icdinode *to = &ip->i_d;
struct inode *inode = VFS_I(ip);
- to->di_mode = be16_to_cpu(from->di_mode);
- to->di_version = from ->di_version;
/*
* Convert v1 inodes immediately to v2 inode format as this is the
* minimum inode version format we support in the rest of the code.
*/
+ to->di_version = from->di_version;
if (to->di_version == 1) {
set_nlink(inode, be16_to_cpu(from->di_onlink));
to->di_projid_lo = 0;
inode->i_ctime.tv_sec = (int)be32_to_cpu(from->di_ctime.t_sec);
inode->i_ctime.tv_nsec = (int)be32_to_cpu(from->di_ctime.t_nsec);
inode->i_generation = be32_to_cpu(from->di_gen);
+ inode->i_mode = be16_to_cpu(from->di_mode);
to->di_size = be64_to_cpu(from->di_size);
to->di_nblocks = be64_to_cpu(from->di_nblocks);
to->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
to->di_onlink = 0;
- to->di_mode = cpu_to_be16(from->di_mode);
to->di_version = from->di_version;
to->di_format = from->di_format;
to->di_uid = cpu_to_be32(from->di_uid);
to->di_ctime.t_nsec = cpu_to_be32(inode->i_ctime.tv_nsec);
to->di_nlink = cpu_to_be32(inode->i_nlink);
to->di_gen = cpu_to_be32(inode->i_generation);
+ to->di_mode = cpu_to_be16(inode->i_mode);
to->di_size = cpu_to_be64(from->di_size);
to->di_nblocks = cpu_to_be64(from->di_nblocks);
* the inode is already free and not try to mess
* with the uninitialized part of it.
*/
- ip->i_d.di_mode = 0;
+ VFS_I(ip)->i_mode = 0;
}
ASSERT(ip->i_d.di_version >= 2);
* format specific structures at the appropriate time.
*/
struct xfs_icdinode {
- __uint16_t di_mode; /* mode and type of file */
__int8_t di_version; /* inode version */
__int8_t di_format; /* format of di_c data */
__uint16_t di_flushiter; /* incremented on flush */
return -EFSCORRUPTED;
}
- switch (ip->i_d.di_mode & S_IFMT) {
+ switch (VFS_I(ip)->i_mode & S_IFMT) {
case S_IFIFO:
case S_IFCHR:
case S_IFBLK:
libxfs_trans_ijoin(tp, ip, 0);
- ip->i_d.di_mode &= ~S_ISUID;
+ VFS_I(ip)->i_mode &= ~S_ISUID;
/*
* Note that we don't have to worry about mandatory
* on, but if it was on then mandatory locking wouldn't
* have been enabled.
*/
- if (ip->i_d.di_mode & S_IXGRP)
- ip->i_d.di_mode &= ~S_ISGID;
+ if (VFS_I(ip)->i_mode & S_IXGRP)
+ VFS_I(ip)->i_mode &= ~S_ISGID;
libxfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
memset(&ip->i_d, 0, sizeof(ip->i_d));
- ip->i_d.di_mode = S_IFREG;
+ VFS_I(ip)->i_mode = S_IFREG;
ip->i_d.di_version = vers;
ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
memset(&ip->i_d, 0, sizeof(ip->i_d));
- ip->i_d.di_mode = S_IFREG;
+ VFS_I(ip)->i_mode = S_IFREG;
ip->i_d.di_version = vers;
ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
memset(&ip->i_d, 0, sizeof(ip->i_d));
- ip->i_d.di_mode = (__uint16_t) mode|S_IFDIR;
+ VFS_I(ip)->i_mode = mode|S_IFDIR;
ip->i_d.di_version = vers;
ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
if ((err = -libxfs_iget(mp, NULL, ino, 0, &ino_p, 0)))
do_error(_("%d - couldn't iget disconnected inode\n"), err);
- xname.type = xfs_mode_to_ftype[(ino_p->i_d.di_mode & S_IFMT)>>S_SHIFT];
+ xname.type = xfs_mode_to_ftype[(VFS_I(ino_p)->i_mode & S_IFMT)>>S_SHIFT];
if (isa_dir) {
irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, orphanage_ino),