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

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