550-ubifs-symlink-xattr-support.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. --- a/fs/ubifs/file.c
  2. +++ b/fs/ubifs/file.c
  3. @@ -1575,6 +1575,12 @@ const struct inode_operations ubifs_syml
  4. .follow_link = ubifs_follow_link,
  5. .setattr = ubifs_setattr,
  6. .getattr = ubifs_getattr,
  7. +#ifdef CONFIG_UBIFS_FS_XATTR
  8. + .setxattr = ubifs_setxattr,
  9. + .getxattr = ubifs_getxattr,
  10. + .listxattr = ubifs_listxattr,
  11. + .removexattr = ubifs_removexattr,
  12. +#endif
  13. };
  14. const struct file_operations ubifs_file_operations = {
  15. --- a/fs/ubifs/journal.c
  16. +++ b/fs/ubifs/journal.c
  17. @@ -553,7 +553,8 @@ int ubifs_jnl_update(struct ubifs_info *
  18. dbg_jnl("ino %lu, dent '%.*s', data len %d in dir ino %lu",
  19. inode->i_ino, nm->len, nm->name, ui->data_len, dir->i_ino);
  20. - ubifs_assert(dir_ui->data_len == 0);
  21. + if (!xent)
  22. + ubifs_assert(dir_ui->data_len == 0);
  23. ubifs_assert(mutex_is_locked(&dir_ui->ui_mutex));
  24. dlen = UBIFS_DENT_NODE_SZ + nm->len + 1;
  25. @@ -573,6 +574,13 @@ int ubifs_jnl_update(struct ubifs_info *
  26. aligned_dlen = ALIGN(dlen, 8);
  27. aligned_ilen = ALIGN(ilen, 8);
  28. len = aligned_dlen + aligned_ilen + UBIFS_INO_NODE_SZ;
  29. + if (xent) {
  30. + /*
  31. + * Make sure to account for dir_ui->data_len in
  32. + * length calculation in case there is extended attribute.
  33. + */
  34. + len += dir_ui->data_len;
  35. + }
  36. dent = kmalloc(len, GFP_NOFS);
  37. if (!dent)
  38. return -ENOMEM;
  39. @@ -649,7 +657,8 @@ int ubifs_jnl_update(struct ubifs_info *
  40. ino_key_init(c, &ino_key, dir->i_ino);
  41. ino_offs += aligned_ilen;
  42. - err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs, UBIFS_INO_NODE_SZ);
  43. + err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs,
  44. + UBIFS_INO_NODE_SZ + dir_ui->data_len);
  45. if (err)
  46. goto out_ro;
  47. --- a/fs/ubifs/xattr.c
  48. +++ b/fs/ubifs/xattr.c
  49. @@ -209,12 +209,12 @@ static int change_xattr(struct ubifs_inf
  50. goto out_free;
  51. }
  52. inode->i_size = ui->ui_size = size;
  53. - ui->data_len = size;
  54. mutex_lock(&host_ui->ui_mutex);
  55. host->i_ctime = ubifs_current_time(host);
  56. host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
  57. host_ui->xattr_size += CALC_XATTR_BYTES(size);
  58. + ui->data_len = size;
  59. /*
  60. * It is important to write the host inode after the xattr inode