Commit f28ac91b0541a49d5bc7bfb9f0efd5289a7dd181
Committed by
Linus Torvalds
1 parent
848f3fce45
Exists in
master
and in
7 other branches
[PATCH] cifs: CIFS ioctl needed by umount.cifs utility
Signed-off-by: Steve French (sfrench@us.ibm.com) Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 3 changed files with 28 additions and 9 deletions Side-by-side Diff
fs/cifs/cifsfs.c
... | ... | @@ -190,6 +190,7 @@ |
190 | 190 | |
191 | 191 | #ifdef CONFIG_CIFS_EXPERIMENTAL |
192 | 192 | /* BB we could add a second check for a QFS Unix capability bit */ |
193 | +/* BB FIXME check CIFS_POSIX_EXTENSIONS Unix cap first FIXME BB */ | |
193 | 194 | if (pTcon->ses->capabilities & CAP_UNIX) |
194 | 195 | rc = CIFSSMBQFSPosixInfo(xid, pTcon, buf); |
195 | 196 | |
... | ... | @@ -599,6 +600,9 @@ |
599 | 600 | #ifdef CONFIG_CIFS_EXPERIMENTAL |
600 | 601 | .dir_notify = cifs_dir_notify, |
601 | 602 | #endif /* CONFIG_CIFS_EXPERIMENTAL */ |
603 | +#ifdef CONFIG_CIFS_POSIX | |
604 | + .ioctl = cifs_ioctl, | |
605 | +#endif /* CONFIG_CIFS_POSIX */ | |
602 | 606 | }; |
603 | 607 | |
604 | 608 | static void |
fs/cifs/cifspdu.h
... | ... | @@ -1556,7 +1556,7 @@ |
1556 | 1556 | #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */ |
1557 | 1557 | #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */ |
1558 | 1558 | #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */ |
1559 | - | |
1559 | +#define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */ | |
1560 | 1560 | typedef struct { |
1561 | 1561 | /* For undefined recommended transfer size return -1 in that field */ |
1562 | 1562 | __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */ |
fs/cifs/ioctl.c
... | ... | @@ -29,6 +29,8 @@ |
29 | 29 | #include "cifs_debug.h" |
30 | 30 | #include "cifsfs.h" |
31 | 31 | |
32 | +#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2) | |
33 | + | |
32 | 34 | int cifs_ioctl (struct inode * inode, struct file * filep, |
33 | 35 | unsigned int command, unsigned long arg) |
34 | 36 | { |
35 | 37 | |
... | ... | @@ -36,8 +38,8 @@ |
36 | 38 | #ifdef CONFIG_CIFS_POSIX |
37 | 39 | __u64 ExtAttrBits = 0; |
38 | 40 | __u64 ExtAttrMask = 0; |
39 | - __u64 caps; | |
40 | 41 | #endif /* CONFIG_CIFS_POSIX */ |
42 | + __u64 caps; | |
41 | 43 | int xid; |
42 | 44 | struct cifs_sb_info *cifs_sb; |
43 | 45 | struct cifsTconInfo *tcon; |
44 | 46 | |
45 | 47 | |
... | ... | @@ -46,12 +48,11 @@ |
46 | 48 | |
47 | 49 | xid = GetXid(); |
48 | 50 | |
51 | + cFYI(1,("ioctl file %p cmd %u arg %lu",filep,command,arg)); | |
52 | + | |
49 | 53 | cifs_sb = CIFS_SB(inode->i_sb); |
50 | 54 | tcon = cifs_sb->tcon; |
51 | - if (pSMBFile == NULL) | |
52 | - goto cifs_ioctl_out; | |
53 | 55 | |
54 | -#ifdef CONFIG_CIFS_POSIX | |
55 | 56 | if(tcon) |
56 | 57 | caps = le64_to_cpu(tcon->fsUnixInfo.Capability); |
57 | 58 | else { |
58 | 59 | |
59 | 60 | |
... | ... | @@ -59,10 +60,22 @@ |
59 | 60 | goto cifs_ioctl_out; |
60 | 61 | } |
61 | 62 | |
62 | - cFYI(1,("ioctl file %p cmd %u arg %lu",filep,command,arg)); | |
63 | 63 | switch(command) { |
64 | + case CIFS_IOC_CHECKUMOUNT: | |
65 | + cFYI(1,("User unmount attempted")); | |
66 | + /* BB FIXME - add missing code here FIXME */ | |
67 | + if(cifs_sb->mnt_uid == current->uid) | |
68 | + rc = 0; | |
69 | + else { | |
70 | + rc = -EACCES; | |
71 | + cFYI(1,("uids do not match")); | |
72 | + } | |
73 | + break; | |
74 | +#ifdef CONFIG_CIFS_POSIX | |
64 | 75 | case EXT2_IOC_GETFLAGS: |
65 | 76 | if(CIFS_UNIX_EXTATTR_CAP & caps) { |
77 | + if (pSMBFile == NULL) | |
78 | + goto cifs_ioctl_out; | |
66 | 79 | rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid, |
67 | 80 | &ExtAttrBits, &ExtAttrMask); |
68 | 81 | if(rc == 0) |
69 | 82 | |
70 | 83 | |
71 | 84 | |
... | ... | @@ -78,17 +91,19 @@ |
78 | 91 | rc = -EFAULT; |
79 | 92 | goto cifs_ioctl_out; |
80 | 93 | } |
81 | - /* rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid, | |
94 | + if (pSMBFile == NULL) | |
95 | + goto cifs_ioctl_out; | |
96 | + /* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid, | |
82 | 97 | extAttrBits, &ExtAttrMask);*/ |
83 | 98 | |
84 | 99 | } |
85 | 100 | cFYI(1,("set flags not implemented yet")); |
86 | 101 | break; |
102 | +#endif /* CONFIG_CIFS_POSIX */ | |
87 | 103 | default: |
88 | 104 | cFYI(1,("unsupported ioctl")); |
89 | - return rc; | |
105 | + break; | |
90 | 106 | } |
91 | -#endif /* CONFIG_CIFS_POSIX */ | |
92 | 107 | |
93 | 108 | cifs_ioctl_out: |
94 | 109 | FreeXid(xid); |