ioctl.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * fs/cifs/ioctl.c
  3. *
  4. * vfs operations that deal with io control
  5. *
  6. * Copyright (C) International Business Machines Corp., 2005,2013
  7. * Author(s): Steve French (sfrench@us.ibm.com)
  8. *
  9. * This library is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as published
  11. * by the Free Software Foundation; either version 2.1 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  17. * the GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <linux/fs.h>
  24. #include "cifspdu.h"
  25. #include "cifsglob.h"
  26. #include "cifsproto.h"
  27. #include "cifs_debug.h"
  28. #include "cifsfs.h"
  29. long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
  30. {
  31. struct inode *inode = file_inode(filep);
  32. int rc = -ENOTTY; /* strange error - but the precedent */
  33. unsigned int xid;
  34. struct cifs_sb_info *cifs_sb;
  35. struct cifsFileInfo *pSMBFile = filep->private_data;
  36. struct cifs_tcon *tcon;
  37. __u64 ExtAttrBits = 0;
  38. __u64 caps;
  39. xid = get_xid();
  40. cifs_dbg(FYI, "ioctl file %p cmd %u arg %lu\n", filep, command, arg);
  41. cifs_sb = CIFS_SB(inode->i_sb);
  42. switch (command) {
  43. case FS_IOC_GETFLAGS:
  44. if (pSMBFile == NULL)
  45. break;
  46. tcon = tlink_tcon(pSMBFile->tlink);
  47. caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
  48. #ifdef CONFIG_CIFS_POSIX
  49. if (CIFS_UNIX_EXTATTR_CAP & caps) {
  50. __u64 ExtAttrMask = 0;
  51. rc = CIFSGetExtAttr(xid, tcon,
  52. pSMBFile->fid.netfid,
  53. &ExtAttrBits, &ExtAttrMask);
  54. if (rc == 0)
  55. rc = put_user(ExtAttrBits &
  56. FS_FL_USER_VISIBLE,
  57. (int __user *)arg);
  58. if (rc != EOPNOTSUPP)
  59. break;
  60. }
  61. #endif /* CONFIG_CIFS_POSIX */
  62. rc = 0;
  63. if (CIFS_I(inode)->cifsAttrs & ATTR_COMPRESSED) {
  64. /* add in the compressed bit */
  65. ExtAttrBits = FS_COMPR_FL;
  66. rc = put_user(ExtAttrBits & FS_FL_USER_VISIBLE,
  67. (int __user *)arg);
  68. }
  69. break;
  70. case FS_IOC_SETFLAGS:
  71. if (pSMBFile == NULL)
  72. break;
  73. tcon = tlink_tcon(pSMBFile->tlink);
  74. caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
  75. if (get_user(ExtAttrBits, (int __user *)arg)) {
  76. rc = -EFAULT;
  77. break;
  78. }
  79. /*
  80. * if (CIFS_UNIX_EXTATTR_CAP & caps)
  81. * rc = CIFSSetExtAttr(xid, tcon,
  82. * pSMBFile->fid.netfid,
  83. * extAttrBits,
  84. * &ExtAttrMask);
  85. * if (rc != EOPNOTSUPP)
  86. * break;
  87. */
  88. /* Currently only flag we can set is compressed flag */
  89. if ((ExtAttrBits & FS_COMPR_FL) == 0)
  90. break;
  91. /* Try to set compress flag */
  92. if (tcon->ses->server->ops->set_compression) {
  93. rc = tcon->ses->server->ops->set_compression(
  94. xid, tcon, pSMBFile);
  95. cifs_dbg(FYI, "set compress flag rc %d\n", rc);
  96. }
  97. break;
  98. default:
  99. cifs_dbg(FYI, "unsupported ioctl\n");
  100. break;
  101. }
  102. free_xid(xid);
  103. return rc;
  104. }