diff options
author | Stefan Metzmacher <metze@samba.org> | 2010-08-05 15:13:44 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2010-09-29 15:04:30 -0400 |
commit | 0fd43ae4758b2841656afda4439b80e8a3603af2 (patch) | |
tree | e2d68bd9303c53a5f391c0b493b12e68fe58e43d /fs/cifs/link.c | |
parent | 8bfb50a882ccd9804929876470f74edcb23d2326 (diff) |
cifs: implement CIFSQueryMFSymLink()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/link.c')
-rw-r--r-- | fs/cifs/link.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/fs/cifs/link.c b/fs/cifs/link.c index bec212b09a02..6e4e8957595d 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c | |||
@@ -91,6 +91,56 @@ CIFSParseMFSymlink(const u8 *buf, | |||
91 | return 0; | 91 | return 0; |
92 | } | 92 | } |
93 | 93 | ||
94 | static int | ||
95 | CIFSQueryMFSymLink(const int xid, struct cifsTconInfo *tcon, | ||
96 | const unsigned char *searchName, char **symlinkinfo, | ||
97 | const struct nls_table *nls_codepage, int remap) | ||
98 | { | ||
99 | int rc; | ||
100 | int oplock = 0; | ||
101 | __u16 netfid = 0; | ||
102 | u8 *buf; | ||
103 | char *pbuf; | ||
104 | unsigned int bytes_read = 0; | ||
105 | int buf_type = CIFS_NO_BUFFER; | ||
106 | unsigned int link_len = 0; | ||
107 | FILE_ALL_INFO file_info; | ||
108 | |||
109 | rc = CIFSSMBOpen(xid, tcon, searchName, FILE_OPEN, GENERIC_READ, | ||
110 | CREATE_NOT_DIR, &netfid, &oplock, &file_info, | ||
111 | nls_codepage, remap); | ||
112 | if (rc != 0) | ||
113 | return rc; | ||
114 | |||
115 | if (file_info.EndOfFile != CIFS_MF_SYMLINK_FILE_SIZE) { | ||
116 | CIFSSMBClose(xid, tcon, netfid); | ||
117 | /* it's not a symlink */ | ||
118 | return -EINVAL; | ||
119 | } | ||
120 | |||
121 | buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL); | ||
122 | if (!buf) | ||
123 | return -ENOMEM; | ||
124 | pbuf = buf; | ||
125 | |||
126 | rc = CIFSSMBRead(xid, tcon, netfid, | ||
127 | CIFS_MF_SYMLINK_FILE_SIZE /* length */, | ||
128 | 0 /* offset */, | ||
129 | &bytes_read, &pbuf, &buf_type); | ||
130 | CIFSSMBClose(xid, tcon, netfid); | ||
131 | if (rc != 0) { | ||
132 | kfree(buf); | ||
133 | return rc; | ||
134 | } | ||
135 | |||
136 | rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, symlinkinfo); | ||
137 | kfree(buf); | ||
138 | if (rc != 0) | ||
139 | return rc; | ||
140 | |||
141 | return 0; | ||
142 | } | ||
143 | |||
94 | bool | 144 | bool |
95 | CIFSCouldBeMFSymlink(const struct cifs_fattr *fattr) | 145 | CIFSCouldBeMFSymlink(const struct cifs_fattr *fattr) |
96 | { | 146 | { |