Commit 77d91317 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull UDF and quota updates from Jan Kara:
 "This contains a rewrite of UDF handling of filename encoding to fix
  remaining overflow issues from Andrew Gabbasov and quota changes to
  support new Q_[X]GETNEXTQUOTA quotactl for VFS quota formats"

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  quota: Fix possible GPF due to uninitialised pointers
  ext4: Make Q_GETNEXTQUOTA work for quota in hidden inodes
  quota: Forbid Q_GETQUOTA and Q_GETNEXTQUOTA for frozen filesystem
  quota: Fix possible races during quota loading
  ocfs2: Implement get_next_id()
  quota_v2: Implement get_next_id() for V2 quota format
  quota: Add support for ->get_nextdqblk() for VFS quota
  udf: Merge linux specific translation into CS0 conversion function
  udf: Remove struct ustr as non-needed intermediate storage
  udf: Use separate buffer for copying split names
  udf: Adjust UDF_NAME_LEN to better reflect actual restrictions
  udf: Join functions for UTF8 and NLS conversions
  udf: Parameterize output length in udf_put_filename
  quota: Allow Q_GETQUOTA for frozen filesystem
  quota: Fixup comments about return value of Q_[X]GETNEXTQUOTA
parents 53d2e697 ab73ef46
...@@ -1129,6 +1129,7 @@ static const struct dquot_operations ext4_quota_operations = { ...@@ -1129,6 +1129,7 @@ static const struct dquot_operations ext4_quota_operations = {
.alloc_dquot = dquot_alloc, .alloc_dquot = dquot_alloc,
.destroy_dquot = dquot_destroy, .destroy_dquot = dquot_destroy,
.get_projid = ext4_get_projid, .get_projid = ext4_get_projid,
.get_next_id = dquot_get_next_id,
}; };
static const struct quotactl_ops ext4_qctl_operations = { static const struct quotactl_ops ext4_qctl_operations = {
...@@ -1138,7 +1139,8 @@ static const struct quotactl_ops ext4_qctl_operations = { ...@@ -1138,7 +1139,8 @@ static const struct quotactl_ops ext4_qctl_operations = {
.get_state = dquot_get_state, .get_state = dquot_get_state,
.set_info = dquot_set_dqinfo, .set_info = dquot_set_dqinfo,
.get_dqblk = dquot_get_dqblk, .get_dqblk = dquot_get_dqblk,
.set_dqblk = dquot_set_dqblk .set_dqblk = dquot_set_dqblk,
.get_nextdqblk = dquot_get_next_dqblk,
}; };
#endif #endif
......
...@@ -2035,6 +2035,8 @@ DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_release_dquot); ...@@ -2035,6 +2035,8 @@ DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_release_dquot);
DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_acquire_dquot); DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_acquire_dquot);
DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_get_next_id);
DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_mark_dquot_dirty); DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_mark_dquot_dirty);
/* End of trace events for fs/ocfs2/quota_global.c. */ /* End of trace events for fs/ocfs2/quota_global.c. */
......
...@@ -860,6 +860,30 @@ static int ocfs2_acquire_dquot(struct dquot *dquot) ...@@ -860,6 +860,30 @@ static int ocfs2_acquire_dquot(struct dquot *dquot)
return status; return status;
} }
static int ocfs2_get_next_id(struct super_block *sb, struct kqid *qid)
{
int type = qid->type;
struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
int status = 0;
trace_ocfs2_get_next_id(from_kqid(&init_user_ns, *qid), type);
status = ocfs2_lock_global_qf(info, 0);
if (status < 0)
goto out;
status = ocfs2_qinfo_lock(info, 0);
if (status < 0)
goto out_global;
status = qtree_get_next_id(&info->dqi_gi, qid);
ocfs2_qinfo_unlock(info, 0);
out_global:
ocfs2_unlock_global_qf(info, 0);
out:
/* Avoid logging ENOENT since it just means there isn't next ID */
if (status && status != -ENOENT)
mlog_errno(status);
return status;
}
static int ocfs2_mark_dquot_dirty(struct dquot *dquot) static int ocfs2_mark_dquot_dirty(struct dquot *dquot)
{ {
unsigned long mask = (1 << (DQ_LASTSET_B + QIF_ILIMITS_B)) | unsigned long mask = (1 << (DQ_LASTSET_B + QIF_ILIMITS_B)) |
...@@ -968,4 +992,5 @@ const struct dquot_operations ocfs2_quota_operations = { ...@@ -968,4 +992,5 @@ const struct dquot_operations ocfs2_quota_operations = {
.write_info = ocfs2_write_info, .write_info = ocfs2_write_info,
.alloc_dquot = ocfs2_alloc_dquot, .alloc_dquot = ocfs2_alloc_dquot,
.destroy_dquot = ocfs2_destroy_dquot, .destroy_dquot = ocfs2_destroy_dquot,
.get_next_id = ocfs2_get_next_id,
}; };
...@@ -411,6 +411,8 @@ int dquot_acquire(struct dquot *dquot) ...@@ -411,6 +411,8 @@ int dquot_acquire(struct dquot *dquot)
ret = dqopt->ops[dquot->dq_id.type]->read_dqblk(dquot); ret = dqopt->ops[dquot->dq_id.type]->read_dqblk(dquot);
if (ret < 0) if (ret < 0)
goto out_iolock; goto out_iolock;
/* Make sure flags update is visible after dquot has been filled */
smp_mb__before_atomic();
set_bit(DQ_READ_B, &dquot->dq_flags); set_bit(DQ_READ_B, &dquot->dq_flags);
/* Instantiate dquot if needed */ /* Instantiate dquot if needed */
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) {
...@@ -427,6 +429,11 @@ int dquot_acquire(struct dquot *dquot) ...@@ -427,6 +429,11 @@ int dquot_acquire(struct dquot *dquot)
goto out_iolock; goto out_iolock;
} }
} }
/*
* Make sure flags update is visible after on-disk struct has been
* allocated. Paired with smp_rmb() in dqget().
*/
smp_mb__before_atomic();
set_bit(DQ_ACTIVE_B, &dquot->dq_flags); set_bit(DQ_ACTIVE_B, &dquot->dq_flags);
out_iolock: out_iolock:
mutex_unlock(&dqopt->dqio_mutex); mutex_unlock(&dqopt->dqio_mutex);
...@@ -887,6 +894,11 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid) ...@@ -887,6 +894,11 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid)
goto out; goto out;
} }
} }
/*
* Make sure following reads see filled structure - paired with
* smp_mb__before_atomic() in dquot_acquire().
*/
smp_rmb();
#ifdef CONFIG_QUOTA_DEBUG #ifdef CONFIG_QUOTA_DEBUG
BUG_ON(!dquot->dq_sb); /* Has somebody invalidated entry under us? */ BUG_ON(!dquot->dq_sb); /* Has somebody invalidated entry under us? */
#endif #endif
...@@ -1398,7 +1410,7 @@ static int dquot_active(const struct inode *inode) ...@@ -1398,7 +1410,7 @@ static int dquot_active(const struct inode *inode)
static int __dquot_initialize(struct inode *inode, int type) static int __dquot_initialize(struct inode *inode, int type)
{ {
int cnt, init_needed = 0; int cnt, init_needed = 0;
struct dquot **dquots, *got[MAXQUOTAS]; struct dquot **dquots, *got[MAXQUOTAS] = {};
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
qsize_t rsv; qsize_t rsv;
int ret = 0; int ret = 0;
...@@ -1415,7 +1427,6 @@ static int __dquot_initialize(struct inode *inode, int type) ...@@ -1415,7 +1427,6 @@ static int __dquot_initialize(struct inode *inode, int type)
int rc; int rc;
struct dquot *dquot; struct dquot *dquot;
got[cnt] = NULL;
if (type != -1 && cnt != type) if (type != -1 && cnt != type)
continue; continue;
/* /*
...@@ -2031,6 +2042,21 @@ int dquot_commit_info(struct super_block *sb, int type) ...@@ -2031,6 +2042,21 @@ int dquot_commit_info(struct super_block *sb, int type)
} }
EXPORT_SYMBOL(dquot_commit_info); EXPORT_SYMBOL(dquot_commit_info);
int dquot_get_next_id(struct super_block *sb, struct kqid *qid)
{
struct quota_info *dqopt = sb_dqopt(sb);
int err;
if (!dqopt->ops[qid->type]->get_next_id)
return -ENOSYS;
mutex_lock(&dqopt->dqio_mutex);
err = dqopt->ops[qid->type]->get_next_id(sb, qid);
mutex_unlock(&dqopt->dqio_mutex);
return err;
}
EXPORT_SYMBOL(dquot_get_next_id);
/* /*
* Definitions of diskquota operations. * Definitions of diskquota operations.
*/ */
...@@ -2042,6 +2068,7 @@ const struct dquot_operations dquot_operations = { ...@@ -2042,6 +2068,7 @@ const struct dquot_operations dquot_operations = {
.write_info = dquot_commit_info, .write_info = dquot_commit_info,
.alloc_dquot = dquot_alloc, .alloc_dquot = dquot_alloc,
.destroy_dquot = dquot_destroy, .destroy_dquot = dquot_destroy,
.get_next_id = dquot_get_next_id,
}; };
EXPORT_SYMBOL(dquot_operations); EXPORT_SYMBOL(dquot_operations);
...@@ -2563,6 +2590,27 @@ int dquot_get_dqblk(struct super_block *sb, struct kqid qid, ...@@ -2563,6 +2590,27 @@ int dquot_get_dqblk(struct super_block *sb, struct kqid qid,
} }
EXPORT_SYMBOL(dquot_get_dqblk); EXPORT_SYMBOL(dquot_get_dqblk);
int dquot_get_next_dqblk(struct super_block *sb, struct kqid *qid,
struct qc_dqblk *di)
{
struct dquot *dquot;
int err;
if (!sb->dq_op->get_next_id)
return -ENOSYS;
err = sb->dq_op->get_next_id(sb, qid);
if (err < 0)
return err;
dquot = dqget(sb, *qid);
if (IS_ERR(dquot))
return PTR_ERR(dquot);
do_get_dqblk(dquot, di);
dqput(dquot);
return 0;
}
EXPORT_SYMBOL(dquot_get_next_dqblk);
#define VFS_QC_MASK \ #define VFS_QC_MASK \
(QC_SPACE | QC_SPC_SOFT | QC_SPC_HARD | \ (QC_SPACE | QC_SPC_SOFT | QC_SPC_HARD | \
QC_INO_COUNT | QC_INO_SOFT | QC_INO_HARD | \ QC_INO_COUNT | QC_INO_SOFT | QC_INO_HARD | \
...@@ -2763,6 +2811,7 @@ const struct quotactl_ops dquot_quotactl_ops = { ...@@ -2763,6 +2811,7 @@ const struct quotactl_ops dquot_quotactl_ops = {
.get_state = dquot_get_state, .get_state = dquot_get_state,
.set_info = dquot_set_dqinfo, .set_info = dquot_set_dqinfo,
.get_dqblk = dquot_get_dqblk, .get_dqblk = dquot_get_dqblk,
.get_nextdqblk = dquot_get_next_dqblk,
.set_dqblk = dquot_set_dqblk .set_dqblk = dquot_set_dqblk
}; };
EXPORT_SYMBOL(dquot_quotactl_ops); EXPORT_SYMBOL(dquot_quotactl_ops);
...@@ -2774,6 +2823,7 @@ const struct quotactl_ops dquot_quotactl_sysfile_ops = { ...@@ -2774,6 +2823,7 @@ const struct quotactl_ops dquot_quotactl_sysfile_ops = {
.get_state = dquot_get_state, .get_state = dquot_get_state,
.set_info = dquot_set_dqinfo, .set_info = dquot_set_dqinfo,
.get_dqblk = dquot_get_dqblk, .get_dqblk = dquot_get_dqblk,
.get_nextdqblk = dquot_get_next_dqblk,
.set_dqblk = dquot_set_dqblk .set_dqblk = dquot_set_dqblk
}; };
EXPORT_SYMBOL(dquot_quotactl_sysfile_ops); EXPORT_SYMBOL(dquot_quotactl_sysfile_ops);
......
...@@ -224,7 +224,7 @@ static int quota_getquota(struct super_block *sb, int type, qid_t id, ...@@ -224,7 +224,7 @@ static int quota_getquota(struct super_block *sb, int type, qid_t id,
/* /*
* Return quota for next active quota >= this id, if any exists, * Return quota for next active quota >= this id, if any exists,
* otherwise return -ESRCH via ->get_nextdqblk * otherwise return -ENOENT via ->get_nextdqblk
*/ */
static int quota_getnextquota(struct super_block *sb, int type, qid_t id, static int quota_getnextquota(struct super_block *sb, int type, qid_t id,
void __user *addr) void __user *addr)
...@@ -655,7 +655,7 @@ static int quota_getxquota(struct super_block *sb, int type, qid_t id, ...@@ -655,7 +655,7 @@ static int quota_getxquota(struct super_block *sb, int type, qid_t id,
/* /*
* Return quota for next active quota >= this id, if any exists, * Return quota for next active quota >= this id, if any exists,
* otherwise return -ESRCH via ->get_nextdqblk. * otherwise return -ENOENT via ->get_nextdqblk.
*/ */
static int quota_getnextxquota(struct super_block *sb, int type, qid_t id, static int quota_getnextxquota(struct super_block *sb, int type, qid_t id,
void __user *addr) void __user *addr)
...@@ -765,10 +765,14 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, ...@@ -765,10 +765,14 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
/* Return 1 if 'cmd' will block on frozen filesystem */ /* Return 1 if 'cmd' will block on frozen filesystem */
static int quotactl_cmd_write(int cmd) static int quotactl_cmd_write(int cmd)
{ {
/*
* We cannot allow Q_GETQUOTA and Q_GETNEXTQUOTA without write access
* as dquot_acquire() may allocate space for new structure and OCFS2
* needs to increment on-disk use count.
*/
switch (cmd) { switch (cmd) {
case Q_GETFMT: case Q_GETFMT:
case Q_GETINFO: case Q_GETINFO:
case Q_GETNEXTQUOTA:
case Q_SYNC: case Q_SYNC:
case Q_XGETQSTAT: case Q_XGETQSTAT:
case Q_XGETQSTATV: case Q_XGETQSTATV:
......
...@@ -22,10 +22,9 @@ MODULE_LICENSE("GPL"); ...@@ -22,10 +22,9 @@ MODULE_LICENSE("GPL");
#define __QUOTA_QT_PARANOIA #define __QUOTA_QT_PARANOIA
static int get_index(struct qtree_mem_dqinfo *info, struct kqid qid, int depth) static int __get_index(struct qtree_mem_dqinfo *info, qid_t id, int depth)
{ {
unsigned int epb = info->dqi_usable_bs >> 2; unsigned int epb = info->dqi_usable_bs >> 2;
qid_t id = from_kqid(&init_user_ns, qid);
depth = info->dqi_qtree_depth - depth - 1; depth = info->dqi_qtree_depth - depth - 1;
while (depth--) while (depth--)
...@@ -33,6 +32,13 @@ static int get_index(struct qtree_mem_dqinfo *info, struct kqid qid, int depth) ...@@ -33,6 +32,13 @@ static int get_index(struct qtree_mem_dqinfo *info, struct kqid qid, int depth)
return id % epb; return id % epb;
} }
static int get_index(struct qtree_mem_dqinfo *info, struct kqid qid, int depth)
{
qid_t id = from_kqid(&init_user_ns, qid);
return __get_index(info, id, depth);
}
/* Number of entries in one blocks */ /* Number of entries in one blocks */
static int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info) static int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info)
{ {
...@@ -668,3 +674,60 @@ int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot) ...@@ -668,3 +674,60 @@ int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
return 0; return 0;
} }
EXPORT_SYMBOL(qtree_release_dquot); EXPORT_SYMBOL(qtree_release_dquot);
static int find_next_id(struct qtree_mem_dqinfo *info, qid_t *id,
unsigned int blk, int depth)
{
char *buf = getdqbuf(info->dqi_usable_bs);
__le32 *ref = (__le32 *)buf;
ssize_t ret;
unsigned int epb = info->dqi_usable_bs >> 2;
unsigned int level_inc = 1;
int i;
if (!buf)
return -ENOMEM;
for (i = depth; i < info->dqi_qtree_depth - 1; i++)
level_inc *= epb;
ret = read_blk(info, blk, buf);
if (ret < 0) {
quota_error(info->dqi_sb,
"Can't read quota tree block %u", blk);
goto out_buf;
}
for (i = __get_index(info, *id, depth); i < epb; i++) {
if (ref[i] == cpu_to_le32(0)) {
*id += level_inc;
continue;
}
if (depth == info->dqi_qtree_depth - 1) {
ret = 0;
goto out_buf;
}
ret = find_next_id(info, id, le32_to_cpu(ref[i]), depth + 1);
if (ret != -ENOENT)
break;
}
if (i == epb) {
ret = -ENOENT;
goto out_buf;
}
out_buf:
kfree(buf);
return ret;
}
int qtree_get_next_id(struct qtree_mem_dqinfo *info, struct kqid *qid)
{
qid_t id = from_kqid(&init_user_ns, *qid);
int ret;
ret = find_next_id(info, &id, QT_TREEOFF, 0);
if (ret < 0)
return ret;
*qid = make_kqid(&init_user_ns, qid->type, id);
return 0;
}
EXPORT_SYMBOL(qtree_get_next_id);
...@@ -304,6 +304,11 @@ static int v2_free_file_info(struct super_block *sb, int type) ...@@ -304,6 +304,11 @@ static int v2_free_file_info(struct super_block *sb, int type)
return 0; return 0;
} }
static int v2_get_next_id(struct super_block *sb, struct kqid *qid)
{
return qtree_get_next_id(sb_dqinfo(sb, qid->type)->dqi_priv, qid);
}
static const struct quota_format_ops v2_format_ops = { static const struct quota_format_ops v2_format_ops = {
.check_quota_file = v2_check_quota_file, .check_quota_file = v2_check_quota_file,
.read_file_info = v2_read_file_info, .read_file_info = v2_read_file_info,
...@@ -312,6 +317,7 @@ static const struct quota_format_ops v2_format_ops = { ...@@ -312,6 +317,7 @@ static const struct quota_format_ops v2_format_ops = {
.read_dqblk = v2_read_dquot, .read_dqblk = v2_read_dquot,
.commit_dqblk = v2_write_dquot, .commit_dqblk = v2_write_dquot,
.release_dqblk = v2_release_dquot, .release_dqblk = v2_release_dquot,
.get_next_id = v2_get_next_id,
}; };
static struct quota_format_type v2r0_quota_format = { static struct quota_format_type v2r0_quota_format = {
......
...@@ -802,6 +802,7 @@ static const struct dquot_operations reiserfs_quota_operations = { ...@@ -802,6 +802,7 @@ static const struct dquot_operations reiserfs_quota_operations = {
.write_info = reiserfs_write_info, .write_info = reiserfs_write_info,
.alloc_dquot = dquot_alloc, .alloc_dquot = dquot_alloc,
.destroy_dquot = dquot_destroy, .destroy_dquot = dquot_destroy,
.get_next_id = dquot_get_next_id,
}; };
static const struct quotactl_ops reiserfs_qctl_operations = { static const struct quotactl_ops reiserfs_qctl_operations = {
......
...@@ -45,7 +45,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx) ...@@ -45,7 +45,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
int block, iblock; int block, iblock;
loff_t nf_pos; loff_t nf_pos;
int flen; int flen;
unsigned char *fname = NULL; unsigned char *fname = NULL, *copy_name = NULL;
unsigned char *nameptr; unsigned char *nameptr;
uint16_t liu; uint16_t liu;
uint8_t lfi; uint8_t lfi;
...@@ -143,7 +143,15 @@ static int udf_readdir(struct file *file, struct dir_context *ctx) ...@@ -143,7 +143,15 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
if (poffset >= lfi) { if (poffset >= lfi) {
nameptr = (char *)(fibh.ebh->b_data + poffset - lfi); nameptr = (char *)(fibh.ebh->b_data + poffset - lfi);
} else { } else {
nameptr = fname; if (!copy_name) {
copy_name = kmalloc(UDF_NAME_LEN,
GFP_NOFS);
if (!copy_name) {
ret = -ENOMEM;
goto out;
}
}
nameptr = copy_name;
memcpy(nameptr, fi->fileIdent + liu, memcpy(nameptr, fi->fileIdent + liu,
lfi - poffset); lfi - poffset);
memcpy(nameptr + lfi - poffset, memcpy(nameptr + lfi - poffset,
...@@ -185,6 +193,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx) ...@@ -185,6 +193,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
brelse(fibh.sbh); brelse(fibh.sbh);
brelse(epos.bh); brelse(epos.bh);
kfree(fname); kfree(fname);
kfree(copy_name);
return ret; return ret;
} }
......
...@@ -165,7 +165,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, ...@@ -165,7 +165,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
struct fileIdentDesc *fi = NULL; struct fileIdentDesc *fi = NULL;
loff_t f_pos; loff_t f_pos;
int block, flen; int block, flen;
unsigned char *fname = NULL; unsigned char *fname = NULL, *copy_name = NULL;
unsigned char *nameptr; unsigned char *nameptr;
uint8_t lfi; uint8_t lfi;
uint16_t liu; uint16_t liu;
...@@ -236,7 +236,15 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, ...@@ -236,7 +236,15 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
nameptr = (uint8_t *)(fibh->ebh->b_data + nameptr = (uint8_t *)(fibh->ebh->b_data +
poffset - lfi); poffset - lfi);
else { else {
nameptr = fname; if (!copy_name) {
copy_name = kmalloc(UDF_NAME_LEN,
GFP_NOFS);
if (!copy_name) {
fi = ERR_PTR(-ENOMEM);
goto out_err;
}
}
nameptr = copy_name;
memcpy(nameptr, fi->fileIdent + liu, memcpy(nameptr, fi->fileIdent + liu,
lfi - poffset); lfi - poffset);
memcpy(nameptr + lfi - poffset, memcpy(nameptr + lfi - poffset,
...@@ -279,6 +287,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, ...@@ -279,6 +287,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
out_ok: out_ok:
brelse(epos.bh); brelse(epos.bh);
kfree(fname); kfree(fname);
kfree(copy_name);
return fi; return fi;
} }
...@@ -291,7 +300,7 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, ...@@ -291,7 +300,7 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
struct udf_fileident_bh fibh; struct udf_fileident_bh fibh;
struct fileIdentDesc *fi; struct fileIdentDesc *fi;
if (dentry->d_name.len > UDF_NAME_LEN - 2) if (dentry->d_name.len > UDF_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
#ifdef UDF_RECOVERY #ifdef UDF_RECOVERY
...@@ -351,7 +360,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, ...@@ -351,7 +360,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
struct udf_inode_info *dinfo; struct udf_inode_info *dinfo;
fibh->sbh = fibh->ebh = NULL; fibh->sbh = fibh->ebh = NULL;
name = kmalloc(UDF_NAME_LEN, GFP_NOFS); name = kmalloc(UDF_NAME_LEN_CS0, GFP_NOFS);
if (!name) { if (!name) {
*err = -ENOMEM; *err = -ENOMEM;
goto out_err; goto out_err;
...@@ -362,8 +371,9 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, ...@@ -362,8 +371,9 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
*err = -EINVAL; *err = -EINVAL;
goto out_err; goto out_err;
} }
namelen = udf_put_filename(sb, dentry->d_name.name, name, namelen = udf_put_filename(sb, dentry->d_name.name,
dentry->d_name.len); dentry->d_name.len,
name, UDF_NAME_LEN_CS0);
if (!namelen) { if (!namelen) {
*err = -ENAMETOOLONG; *err = -ENAMETOOLONG;
goto out_err; goto out_err;
...@@ -914,7 +924,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, ...@@ -914,7 +924,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
iinfo = UDF_I(inode); iinfo = UDF_I(inode);
down_write(&iinfo->i_data_sem); down_write(&iinfo->i_data_sem);
name = kmalloc(UDF_NAME_LEN, GFP_NOFS); name = kmalloc(UDF_NAME_LEN_CS0, GFP_NOFS);
if (!name) { if (!name) {
err = -ENOMEM; err = -ENOMEM;
goto out_no_entry; goto out_no_entry;
...@@ -997,8 +1007,9 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, ...@@ -997,8 +1007,9 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
} }
if (pc->componentType == 5) { if (pc->componentType == 5) {
namelen = udf_put_filename(sb, compstart, name, namelen = udf_put_filename(sb, compstart,
symname - compstart); symname - compstart,
name, UDF_NAME_LEN_CS0);
if (!namelen) if (!namelen)
goto out_no_entry; goto out_no_entry;
......
...@@ -887,18 +887,14 @@ static int udf_find_fileset(struct super_block *sb, ...@@ -887,18 +887,14 @@ static int udf_find_fileset(struct super_block *sb,
static int udf_load_pvoldesc(struct super_block *sb, sector_t block) static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
{ {
struct primaryVolDesc *pvoldesc; struct primaryVolDesc *pvoldesc;
struct ustr *instr, *outstr; uint8_t *outstr;
struct buffer_head *bh; struct buffer_head *bh;
uint16_t ident; uint16_t ident;
int ret = -ENOMEM; int ret = -ENOMEM;
instr = kmalloc(sizeof(struct ustr), GFP_NOFS); outstr = kmalloc(128, GFP_NOFS);
if (!instr)
return -ENOMEM;
outstr = kmalloc(sizeof(struct ustr), GFP_NOFS);
if (!outstr) if (!outstr)
goto out1; return -ENOMEM;
bh = udf_read_tagged(sb, block, block, &ident); bh = udf_read_tagged(sb, block, block, &ident);
if (!bh) { if (!bh) {
...@@ -923,31 +919,25 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block) ...@@ -923,31 +919,25 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
#endif #endif
} }
if (!udf_build_ustr(instr, pvoldesc->volIdent, 32)) { ret = udf_CS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
ret = udf_CS0toUTF8(outstr, instr);
if (ret < 0) if (ret < 0)
goto out_bh; goto out_bh;
strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name, strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret);
outstr->u_len > 31 ? 31 : outstr->u_len);
udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident);
}
if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128)) { ret = udf_CS0toUTF8(outstr, 127, pvoldesc->volSetIdent, 128);
ret = udf_CS0toUTF8(outstr, instr);
if (ret < 0) if (ret < 0)
goto out_bh; goto out_bh;
udf_debug("volSetIdent[] = '%s'\n", outstr->u_name); outstr[ret] = 0;
} udf_debug("volSetIdent[] = '%s'\n", outstr);
ret = 0; ret = 0;
out_bh: out_bh:
brelse(bh); brelse(bh);
out2: out2:
kfree(outstr); kfree(outstr);
out1:
kfree(instr);
return ret; return ret;
} }
...@@ -2358,7 +2348,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -2358,7 +2348,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
le32_to_cpu(lvidiu->numDirs)) : 0) le32_to_cpu(lvidiu->numDirs)) : 0)
+ buf->f_bfree; + buf->f_bfree;
buf->f_ffree = buf->f_bfree; buf->f_ffree = buf->f_bfree;
buf->f_namelen = UDF_NAME_LEN - 2; buf->f_namelen = UDF_NAME_LEN;
buf->f_fsid.val[0] = (u32)id; buf->f_fsid.val[0] = (u32)id;
buf->f_fsid.val[1] = (u32)(id >> 32); buf->f_fsid.val[1] = (u32)(id >> 32);
......
...@@ -49,8 +49,8 @@ extern __printf(3, 4) void _udf_warn(struct super_block *sb, ...@@ -49,8 +49,8 @@ extern __printf(3, 4) void _udf_warn(struct super_block *sb,
#define UDF_EXTENT_FLAG_MASK 0xC0000000 #define UDF_EXTENT_FLAG_MASK 0xC0000000
#define UDF_NAME_PAD 4 #define UDF_NAME_PAD 4
#define UDF_NAME_LEN 256 #define UDF_NAME_LEN 254
#define UDF_PATH_LEN 1023 #define UDF_NAME_LEN_CS0 255
static inline size_t udf_file_entry_alloc_offset(struct inode *inode) static inline size_t udf_file_entry_alloc_offset(struct inode *inode)
{ {
...@@ -106,12 +106,6 @@ struct generic_desc { ...@@ -106,12 +106,6 @@ struct generic_desc {
__le32 volDescSeqNum; __le32 volDescSeqNum;
}; };
struct ustr {
uint8_t u_cmpID;
uint8_t u_name[UDF_NAME_LEN - 2];
uint8_t u_len;
};
/* super.c */ /* super.c */
...@@ -214,12 +208,11 @@ udf_get_lb_pblock(struct super_block *sb, struct kernel_lb_addr *loc, ...@@ -214,12 +208,11 @@ udf_get_lb_pblock(struct super_block *sb, struct kernel_lb_addr *loc,
} }
/* unicode.c */ /* unicode.c */
extern int udf_get_filename(struct super_block *, uint8_t *, int, uint8_t *, extern int udf_get_filename(struct super_block *, const uint8_t *, int,
int); uint8_t *, int);
extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *, extern int udf_put_filename(struct super_block *, const uint8_t *, int,
int); uint8_t *, int);
extern int udf_build_ustr(struct ustr *, dstring *, int); extern int udf_CS0toUTF8(uint8_t *, int, const uint8_t *, int);
extern int udf_CS0toUTF8(struct ustr *, const struct ustr *);
/* ialloc.c */ /* ialloc.c */
extern void udf_free_inode(struct inode *); extern void udf_free_inode(struct inode *);
......
This diff is collapsed.
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define QTREE_DEL_REWRITE 6 #define QTREE_DEL_REWRITE 6
struct dquot; struct dquot;
struct kqid;
/* Operations */ /* Operations */
struct qtree_fmt_operations { struct qtree_fmt_operations {
...@@ -52,5 +53,6 @@ static inline int qtree_depth(struct qtree_mem_dqinfo *info) ...@@ -52,5 +53,6 @@ static inline int qtree_depth(struct qtree_mem_dqinfo *info)
entries *= epb; entries *= epb;
return i; return i;
} }
int qtree_get_next_id(struct qtree_mem_dqinfo *info, struct kqid *qid);
#endif /* _LINUX_DQBLK_QTREE_H */ #endif /* _LINUX_DQBLK_QTREE_H */
...@@ -306,6 +306,7 @@ struct quota_format_ops { ...@@ -306,6 +306,7 @@ struct quota_format_ops {
int (*read_dqblk)(struct dquot *dquot); /* Read structure for one user */ int (*read_dqblk)(struct dquot *dquot); /* Read structure for one user */
int (*commit_dqblk)(struct dquot *dquot); /* Write structure for one user */ int (*commit_dqblk)(struct dquot *dquot); /* Write structure for one user */
int (*release_dqblk)(struct dquot *dquot); /* Called when last reference to dquot is being dropped */ int (*release_dqblk)(struct dquot *dquot); /* Called when last reference to dquot is being dropped */
int (*get_next_id)(struct super_block *sb, struct kqid *qid); /* Get next ID with existing structure in the quota file */
}; };
/* Operations working with dquots */ /* Operations working with dquots */
...@@ -321,6 +322,8 @@ struct dquot_operations { ...@@ -321,6 +322,8 @@ struct dquot_operations {
* quota code only */ * quota code only */
qsize_t *(*get_reserved_space) (struct inode *); qsize_t *(*get_reserved_space) (struct inode *);
int (*get_projid) (struct inode *, kprojid_t *);/* Get project ID */ int (*get_projid) (struct inode *, kprojid_t *);/* Get project ID */
/* Get next ID with active quota structure */
int (*get_next_id) (struct super_block *sb, struct kqid *qid);
}; };
struct path; struct path;
......
...@@ -82,6 +82,7 @@ int dquot_commit(struct dquot *dquot); ...@@ -82,6 +82,7 @@ int dquot_commit(struct dquot *dquot);
int dquot_acquire(struct dquot *dquot); int dquot_acquire(struct dquot *dquot);
int dquot_release(struct dquot *dquot); int dquot_release(struct dquot *dquot);
int dquot_commit_info(struct super_block *sb, int type); int dquot_commit_info(struct super_block *sb, int type);
int dquot_get_next_id(struct super_block *sb, struct kqid *qid);
int dquot_mark_dquot_dirty(struct dquot *dquot); int dquot_mark_dquot_dirty(struct dquot *dquot);
int dquot_file_open(struct inode *inode, struct file *file); int dquot_file_open(struct inode *inode, struct file *file);
...@@ -99,6 +100,8 @@ int dquot_get_state(struct super_block *sb, struct qc_state *state); ...@@ -99,6 +100,8 @@ int dquot_get_state(struct super_block *sb, struct qc_state *state);
int dquot_set_dqinfo(struct super_block *sb, int type, struct qc_info *ii); int dquot_set_dqinfo(struct super_block *sb, int type, struct qc_info *ii);
int dquot_get_dqblk(struct super_block *sb, struct kqid id, int dquot_get_dqblk(struct super_block *sb, struct kqid id,
struct qc_dqblk *di); struct qc_dqblk *di);
int dquot_get_next_dqblk(struct super_block *sb, struct kqid *id,
struct qc_dqblk *di);
int dquot_set_dqblk(struct super_block *sb, struct kqid id, int dquot_set_dqblk(struct super_block *sb, struct kqid id,
struct qc_dqblk *di); struct qc_dqblk *di);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment