static void move_quota_inode(ext2_filsys fs, ext2_ino_t from_ino, ext2_ino_t to_ino, int qtype) { struct ext2_inode inode; char qf_name[QUOTA_NAME_LEN]; /* We need the inode bitmap to be loaded */ if (ext2fs_read_bitmaps(fs)) return; if (ext2fs_read_inode(fs, from_ino, &inode)) return; inode.i_links_count = 1; inode.i_mode = LINUX_S_IFREG | 0600; inode.i_flags = EXT2_IMMUTABLE_FL; if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS) inode.i_flags |= EXT4_EXTENTS_FL; ext2fs_write_new_inode(fs, to_ino, &inode); /* unlink the old inode */ quota_get_qf_name(qtype, QFMT_VFS_V1, qf_name); ext2fs_unlink(fs, EXT2_ROOT_INO, qf_name, from_ino, 0); ext2fs_inode_alloc_stats(fs, from_ino, -1); /* Clear out the original inode in the inode-table block. */ memset(&inode, 0, sizeof(struct ext2_inode)); ext2fs_write_inode(fs, from_ino, &inode); }
const char *quota_get_qf_path(const char *mntpt, int qtype, int fmt, char *path_buf, size_t path_buf_size) { char qf_name[QUOTA_NAME_LEN]; if (!mntpt || !path_buf || !path_buf_size) return NULL; strncpy(path_buf, mntpt, path_buf_size); strncat(path_buf, "/", 1); strncat(path_buf, quota_get_qf_name(qtype, fmt, qf_name), path_buf_size - strlen(path_buf)); return path_buf; }
/* * Returns 0 if not able to find the quota file, otherwise returns its * inode number. */ int quota_file_exists(ext2_filsys fs, int qtype, int fmt) { char qf_name[256]; errcode_t ret; ext2_ino_t ino; if (qtype >= MAXQUOTAS) return -EINVAL; quota_get_qf_name(qtype, QFMT_VFS_V1, qf_name); ret = ext2fs_lookup(fs, EXT2_ROOT_INO, qf_name, strlen(qf_name), 0, &ino); if (ret) return 0; return ino; }
static void move_quota_inode(ext2_filsys fs, ext2_ino_t from_ino, ext2_ino_t to_ino, enum quota_type qtype) { struct ext2_inode inode; errcode_t retval; char qf_name[QUOTA_NAME_LEN]; /* We need the inode bitmap to be loaded */ if (ext2fs_read_bitmaps(fs)) return; retval = ext2fs_read_inode(fs, from_ino, &inode); if (retval) { com_err("ext2fs_read_inode", retval, "%s", _("in move_quota_inode")); return; } inode.i_links_count = 1; inode.i_mode = LINUX_S_IFREG | 0600; inode.i_flags = EXT2_IMMUTABLE_FL; if (ext2fs_has_feature_extents(fs->super)) inode.i_flags |= EXT4_EXTENTS_FL; retval = ext2fs_write_new_inode(fs, to_ino, &inode); if (retval) { com_err("ext2fs_write_new_inode", retval, "%s", _("in move_quota_inode")); return; } /* unlink the old inode */ quota_get_qf_name(qtype, QFMT_VFS_V1, qf_name); ext2fs_unlink(fs, EXT2_ROOT_INO, qf_name, from_ino, 0); ext2fs_inode_alloc_stats(fs, from_ino, -1); /* Clear out the original inode in the inode-table block. */ memset(&inode, 0, sizeof(struct ext2_inode)); ext2fs_write_inode(fs, from_ino, &inode); }