dir.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. /*
  2. * Directory operations for Coda filesystem
  3. * Original version: (C) 1996 P. Braam and M. Callahan
  4. * Rewritten for Linux 2.1. (C) 1997 Carnegie Mellon University
  5. *
  6. * Carnegie Mellon encourages users to contribute improvements to
  7. * the Coda project. Contact Peter Braam (coda@cs.cmu.edu).
  8. */
  9. #include <linux/types.h>
  10. #include <linux/kernel.h>
  11. #include <linux/time.h>
  12. #include <linux/fs.h>
  13. #include <linux/file.h>
  14. #include <linux/stat.h>
  15. #include <linux/errno.h>
  16. #include <linux/string.h>
  17. #include <linux/smp_lock.h>
  18. #include <asm/uaccess.h>
  19. #include <linux/coda.h>
  20. #include <linux/coda_linux.h>
  21. #include <linux/coda_psdev.h>
  22. #include <linux/coda_fs_i.h>
  23. #include <linux/coda_cache.h>
  24. #include "coda_int.h"
  25. /* dir inode-ops */
  26. static int coda_create(struct inode *dir, struct dentry *new, int mode, struct nameidata *nd);
  27. static struct dentry *coda_lookup(struct inode *dir, struct dentry *target, struct nameidata *nd);
  28. static int coda_link(struct dentry *old_dentry, struct inode *dir_inode,
  29. struct dentry *entry);
  30. static int coda_unlink(struct inode *dir_inode, struct dentry *entry);
  31. static int coda_symlink(struct inode *dir_inode, struct dentry *entry,
  32. const char *symname);
  33. static int coda_mkdir(struct inode *dir_inode, struct dentry *entry, int mode);
  34. static int coda_rmdir(struct inode *dir_inode, struct dentry *entry);
  35. static int coda_rename(struct inode *old_inode, struct dentry *old_dentry,
  36. struct inode *new_inode, struct dentry *new_dentry);
  37. /* dir file-ops */
  38. static int coda_readdir(struct file *file, void *buf, filldir_t filldir);
  39. /* dentry ops */
  40. static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd);
  41. static int coda_dentry_delete(struct dentry *);
  42. /* support routines */
  43. static int coda_venus_readdir(struct file *coda_file, void *buf,
  44. filldir_t filldir);
  45. /* same as fs/bad_inode.c */
  46. static int coda_return_EIO(void)
  47. {
  48. return -EIO;
  49. }
  50. #define CODA_EIO_ERROR ((void *) (coda_return_EIO))
  51. static struct dentry_operations coda_dentry_operations =
  52. {
  53. .d_revalidate = coda_dentry_revalidate,
  54. .d_delete = coda_dentry_delete,
  55. };
  56. const struct inode_operations coda_dir_inode_operations =
  57. {
  58. .create = coda_create,
  59. .lookup = coda_lookup,
  60. .link = coda_link,
  61. .unlink = coda_unlink,
  62. .symlink = coda_symlink,
  63. .mkdir = coda_mkdir,
  64. .rmdir = coda_rmdir,
  65. .mknod = CODA_EIO_ERROR,
  66. .rename = coda_rename,
  67. .permission = coda_permission,
  68. .getattr = coda_getattr,
  69. .setattr = coda_setattr,
  70. };
  71. const struct file_operations coda_dir_operations = {
  72. .llseek = generic_file_llseek,
  73. .read = generic_read_dir,
  74. .readdir = coda_readdir,
  75. .open = coda_open,
  76. .release = coda_release,
  77. .fsync = coda_fsync,
  78. };
  79. /* inode operations for directories */
  80. /* access routines: lookup, readlink, permission */
  81. static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struct nameidata *nd)
  82. {
  83. struct inode *inode = NULL;
  84. struct CodaFid resfid = { { 0, } };
  85. int type = 0;
  86. int error = 0;
  87. const char *name = entry->d_name.name;
  88. size_t length = entry->d_name.len;
  89. if (length > CODA_MAXNAMLEN) {
  90. printk(KERN_ERR "name too long: lookup, %s (%*s)\n",
  91. coda_i2s(dir), (int)length, name);
  92. return ERR_PTR(-ENAMETOOLONG);
  93. }
  94. /* control object, create inode on the fly */
  95. if (coda_isroot(dir) && coda_iscontrol(name, length)) {
  96. error = coda_cnode_makectl(&inode, dir->i_sb);
  97. type = CODA_NOCACHE;
  98. goto exit;
  99. }
  100. lock_kernel();
  101. error = venus_lookup(dir->i_sb, coda_i2f(dir), name, length,
  102. &type, &resfid);
  103. if (!error)
  104. error = coda_cnode_make(&inode, &resfid, dir->i_sb);
  105. unlock_kernel();
  106. if (error && error != -ENOENT)
  107. return ERR_PTR(error);
  108. exit:
  109. entry->d_op = &coda_dentry_operations;
  110. if (inode && (type & CODA_NOCACHE))
  111. coda_flag_inode(inode, C_VATTR | C_PURGE);
  112. return d_splice_alias(inode, entry);
  113. }
  114. int coda_permission(struct inode *inode, int mask, struct nameidata *nd)
  115. {
  116. int error = 0;
  117. if (!mask)
  118. return 0;
  119. lock_kernel();
  120. if (coda_cache_check(inode, mask))
  121. goto out;
  122. error = venus_access(inode->i_sb, coda_i2f(inode), mask);
  123. if (!error)
  124. coda_cache_enter(inode, mask);
  125. out:
  126. unlock_kernel();
  127. return error;
  128. }
  129. static inline void coda_dir_update_mtime(struct inode *dir)
  130. {
  131. #ifdef REQUERY_VENUS_FOR_MTIME
  132. /* invalidate the directory cnode's attributes so we refetch the
  133. * attributes from venus next time the inode is referenced */
  134. coda_flag_inode(dir, C_VATTR);
  135. #else
  136. /* optimistically we can also act as if our nose bleeds. The
  137. * granularity of the mtime is coarse anyways so we might actually be
  138. * right most of the time. Note: we only do this for directories. */
  139. dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
  140. #endif
  141. }
  142. /* we have to wrap inc_nlink/drop_nlink because sometimes userspace uses a
  143. * trick to fool GNU find's optimizations. If we can't be sure of the link
  144. * (because of volume mount points) we set i_nlink to 1 which forces find
  145. * to consider every child as a possible directory. We should also never
  146. * see an increment or decrement for deleted directories where i_nlink == 0 */
  147. static inline void coda_dir_inc_nlink(struct inode *dir)
  148. {
  149. if (dir->i_nlink >= 2)
  150. inc_nlink(dir);
  151. }
  152. static inline void coda_dir_drop_nlink(struct inode *dir)
  153. {
  154. if (dir->i_nlink > 2)
  155. drop_nlink(dir);
  156. }
  157. /* creation routines: create, mknod, mkdir, link, symlink */
  158. static int coda_create(struct inode *dir, struct dentry *de, int mode, struct nameidata *nd)
  159. {
  160. int error=0;
  161. const char *name=de->d_name.name;
  162. int length=de->d_name.len;
  163. struct inode *inode;
  164. struct CodaFid newfid;
  165. struct coda_vattr attrs;
  166. lock_kernel();
  167. if (coda_isroot(dir) && coda_iscontrol(name, length)) {
  168. unlock_kernel();
  169. return -EPERM;
  170. }
  171. error = venus_create(dir->i_sb, coda_i2f(dir), name, length,
  172. 0, mode, &newfid, &attrs);
  173. if ( error ) {
  174. unlock_kernel();
  175. d_drop(de);
  176. return error;
  177. }
  178. inode = coda_iget(dir->i_sb, &newfid, &attrs);
  179. if ( IS_ERR(inode) ) {
  180. unlock_kernel();
  181. d_drop(de);
  182. return PTR_ERR(inode);
  183. }
  184. /* invalidate the directory cnode's attributes */
  185. coda_dir_update_mtime(dir);
  186. unlock_kernel();
  187. d_instantiate(de, inode);
  188. return 0;
  189. }
  190. static int coda_mkdir(struct inode *dir, struct dentry *de, int mode)
  191. {
  192. struct inode *inode;
  193. struct coda_vattr attrs;
  194. const char *name = de->d_name.name;
  195. int len = de->d_name.len;
  196. int error;
  197. struct CodaFid newfid;
  198. lock_kernel();
  199. if (coda_isroot(dir) && coda_iscontrol(name, len)) {
  200. unlock_kernel();
  201. return -EPERM;
  202. }
  203. attrs.va_mode = mode;
  204. error = venus_mkdir(dir->i_sb, coda_i2f(dir),
  205. name, len, &newfid, &attrs);
  206. if ( error ) {
  207. unlock_kernel();
  208. d_drop(de);
  209. return error;
  210. }
  211. inode = coda_iget(dir->i_sb, &newfid, &attrs);
  212. if ( IS_ERR(inode) ) {
  213. unlock_kernel();
  214. d_drop(de);
  215. return PTR_ERR(inode);
  216. }
  217. /* invalidate the directory cnode's attributes */
  218. coda_dir_inc_nlink(dir);
  219. coda_dir_update_mtime(dir);
  220. unlock_kernel();
  221. d_instantiate(de, inode);
  222. return 0;
  223. }
  224. /* try to make de an entry in dir_inodde linked to source_de */
  225. static int coda_link(struct dentry *source_de, struct inode *dir_inode,
  226. struct dentry *de)
  227. {
  228. struct inode *inode = source_de->d_inode;
  229. const char * name = de->d_name.name;
  230. int len = de->d_name.len;
  231. int error;
  232. lock_kernel();
  233. if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) {
  234. unlock_kernel();
  235. return -EPERM;
  236. }
  237. error = venus_link(dir_inode->i_sb, coda_i2f(inode),
  238. coda_i2f(dir_inode), (const char *)name, len);
  239. if (error) {
  240. d_drop(de);
  241. goto out;
  242. }
  243. coda_dir_update_mtime(dir_inode);
  244. atomic_inc(&inode->i_count);
  245. d_instantiate(de, inode);
  246. inc_nlink(inode);
  247. out:
  248. unlock_kernel();
  249. return(error);
  250. }
  251. static int coda_symlink(struct inode *dir_inode, struct dentry *de,
  252. const char *symname)
  253. {
  254. const char *name = de->d_name.name;
  255. int len = de->d_name.len;
  256. int symlen;
  257. int error = 0;
  258. lock_kernel();
  259. if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) {
  260. unlock_kernel();
  261. return -EPERM;
  262. }
  263. symlen = strlen(symname);
  264. if ( symlen > CODA_MAXPATHLEN ) {
  265. unlock_kernel();
  266. return -ENAMETOOLONG;
  267. }
  268. /*
  269. * This entry is now negative. Since we do not create
  270. * an inode for the entry we have to drop it.
  271. */
  272. d_drop(de);
  273. error = venus_symlink(dir_inode->i_sb, coda_i2f(dir_inode), name, len,
  274. symname, symlen);
  275. /* mtime is no good anymore */
  276. if ( !error )
  277. coda_dir_update_mtime(dir_inode);
  278. unlock_kernel();
  279. return error;
  280. }
  281. /* destruction routines: unlink, rmdir */
  282. int coda_unlink(struct inode *dir, struct dentry *de)
  283. {
  284. int error;
  285. const char *name = de->d_name.name;
  286. int len = de->d_name.len;
  287. lock_kernel();
  288. error = venus_remove(dir->i_sb, coda_i2f(dir), name, len);
  289. if ( error ) {
  290. unlock_kernel();
  291. return error;
  292. }
  293. coda_dir_update_mtime(dir);
  294. drop_nlink(de->d_inode);
  295. unlock_kernel();
  296. return 0;
  297. }
  298. int coda_rmdir(struct inode *dir, struct dentry *de)
  299. {
  300. const char *name = de->d_name.name;
  301. int len = de->d_name.len;
  302. int error;
  303. lock_kernel();
  304. error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len);
  305. if (!error) {
  306. /* VFS may delete the child */
  307. if (de->d_inode)
  308. de->d_inode->i_nlink = 0;
  309. /* fix the link count of the parent */
  310. coda_dir_drop_nlink(dir);
  311. coda_dir_update_mtime(dir);
  312. }
  313. unlock_kernel();
  314. return error;
  315. }
  316. /* rename */
  317. static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
  318. struct inode *new_dir, struct dentry *new_dentry)
  319. {
  320. const char *old_name = old_dentry->d_name.name;
  321. const char *new_name = new_dentry->d_name.name;
  322. int old_length = old_dentry->d_name.len;
  323. int new_length = new_dentry->d_name.len;
  324. int error;
  325. lock_kernel();
  326. error = venus_rename(old_dir->i_sb, coda_i2f(old_dir),
  327. coda_i2f(new_dir), old_length, new_length,
  328. (const char *) old_name, (const char *)new_name);
  329. if ( !error ) {
  330. if ( new_dentry->d_inode ) {
  331. if ( S_ISDIR(new_dentry->d_inode->i_mode) ) {
  332. coda_dir_drop_nlink(old_dir);
  333. coda_dir_inc_nlink(new_dir);
  334. }
  335. coda_dir_update_mtime(old_dir);
  336. coda_dir_update_mtime(new_dir);
  337. coda_flag_inode(new_dentry->d_inode, C_VATTR);
  338. } else {
  339. coda_flag_inode(old_dir, C_VATTR);
  340. coda_flag_inode(new_dir, C_VATTR);
  341. }
  342. }
  343. unlock_kernel();
  344. return error;
  345. }
  346. /* file operations for directories */
  347. int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir)
  348. {
  349. struct coda_file_info *cfi;
  350. struct file *host_file;
  351. int ret;
  352. cfi = CODA_FTOC(coda_file);
  353. BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
  354. host_file = cfi->cfi_container;
  355. if (!host_file->f_op)
  356. return -ENOTDIR;
  357. if (host_file->f_op->readdir)
  358. {
  359. /* potemkin case: we were handed a directory inode.
  360. * We can't use vfs_readdir because we have to keep the file
  361. * position in sync between the coda_file and the host_file.
  362. * and as such we need grab the inode mutex. */
  363. struct inode *host_inode = host_file->f_path.dentry->d_inode;
  364. mutex_lock(&host_inode->i_mutex);
  365. host_file->f_pos = coda_file->f_pos;
  366. ret = -ENOENT;
  367. if (!IS_DEADDIR(host_inode)) {
  368. ret = host_file->f_op->readdir(host_file, buf, filldir);
  369. file_accessed(host_file);
  370. }
  371. coda_file->f_pos = host_file->f_pos;
  372. mutex_unlock(&host_inode->i_mutex);
  373. }
  374. else /* Venus: we must read Venus dirents from a file */
  375. ret = coda_venus_readdir(coda_file, buf, filldir);
  376. return ret;
  377. }
  378. static inline unsigned int CDT2DT(unsigned char cdt)
  379. {
  380. unsigned int dt;
  381. switch(cdt) {
  382. case CDT_UNKNOWN: dt = DT_UNKNOWN; break;
  383. case CDT_FIFO: dt = DT_FIFO; break;
  384. case CDT_CHR: dt = DT_CHR; break;
  385. case CDT_DIR: dt = DT_DIR; break;
  386. case CDT_BLK: dt = DT_BLK; break;
  387. case CDT_REG: dt = DT_REG; break;
  388. case CDT_LNK: dt = DT_LNK; break;
  389. case CDT_SOCK: dt = DT_SOCK; break;
  390. case CDT_WHT: dt = DT_WHT; break;
  391. default: dt = DT_UNKNOWN; break;
  392. }
  393. return dt;
  394. }
  395. /* support routines */
  396. static int coda_venus_readdir(struct file *coda_file, void *buf,
  397. filldir_t filldir)
  398. {
  399. int result = 0; /* # of entries returned */
  400. struct coda_file_info *cfi;
  401. struct coda_inode_info *cii;
  402. struct file *host_file;
  403. struct dentry *de;
  404. struct venus_dirent *vdir;
  405. unsigned long vdir_size =
  406. (unsigned long)(&((struct venus_dirent *)0)->d_name);
  407. unsigned int type;
  408. struct qstr name;
  409. ino_t ino;
  410. int ret;
  411. cfi = CODA_FTOC(coda_file);
  412. BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
  413. host_file = cfi->cfi_container;
  414. de = coda_file->f_path.dentry;
  415. cii = ITOC(de->d_inode);
  416. vdir = kmalloc(sizeof(*vdir), GFP_KERNEL);
  417. if (!vdir) return -ENOMEM;
  418. if (coda_file->f_pos == 0) {
  419. ret = filldir(buf, ".", 1, 0, de->d_inode->i_ino, DT_DIR);
  420. if (ret < 0)
  421. goto out;
  422. result++;
  423. coda_file->f_pos++;
  424. }
  425. if (coda_file->f_pos == 1) {
  426. ret = filldir(buf, "..", 2, 1, de->d_parent->d_inode->i_ino, DT_DIR);
  427. if (ret < 0)
  428. goto out;
  429. result++;
  430. coda_file->f_pos++;
  431. }
  432. while (1) {
  433. /* read entries from the directory file */
  434. ret = kernel_read(host_file, coda_file->f_pos - 2, (char *)vdir,
  435. sizeof(*vdir));
  436. if (ret < 0) {
  437. printk(KERN_ERR "coda readdir: read dir %s failed %d\n",
  438. coda_f2s(&cii->c_fid), ret);
  439. break;
  440. }
  441. if (ret == 0) break; /* end of directory file reached */
  442. /* catch truncated reads */
  443. if (ret < vdir_size || ret < vdir_size + vdir->d_namlen) {
  444. printk(KERN_ERR "coda readdir: short read on %s\n",
  445. coda_f2s(&cii->c_fid));
  446. ret = -EBADF;
  447. break;
  448. }
  449. /* validate whether the directory file actually makes sense */
  450. if (vdir->d_reclen < vdir_size + vdir->d_namlen) {
  451. printk(KERN_ERR "coda readdir: invalid dir %s\n",
  452. coda_f2s(&cii->c_fid));
  453. ret = -EBADF;
  454. break;
  455. }
  456. name.len = vdir->d_namlen;
  457. name.name = vdir->d_name;
  458. /* Make sure we skip '.' and '..', we already got those */
  459. if (name.name[0] == '.' && (name.len == 1 ||
  460. (vdir->d_name[1] == '.' && name.len == 2)))
  461. vdir->d_fileno = name.len = 0;
  462. /* skip null entries */
  463. if (vdir->d_fileno && name.len) {
  464. /* try to look up this entry in the dcache, that way
  465. * userspace doesn't have to worry about breaking
  466. * getcwd by having mismatched inode numbers for
  467. * internal volume mountpoints. */
  468. ino = find_inode_number(de, &name);
  469. if (!ino) ino = vdir->d_fileno;
  470. type = CDT2DT(vdir->d_type);
  471. ret = filldir(buf, name.name, name.len,
  472. coda_file->f_pos, ino, type);
  473. /* failure means no space for filling in this round */
  474. if (ret < 0) break;
  475. result++;
  476. }
  477. /* we'll always have progress because d_reclen is unsigned and
  478. * we've already established it is non-zero. */
  479. coda_file->f_pos += vdir->d_reclen;
  480. }
  481. out:
  482. kfree(vdir);
  483. return result ? result : ret;
  484. }
  485. /* called when a cache lookup succeeds */
  486. static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd)
  487. {
  488. struct inode *inode = de->d_inode;
  489. struct coda_inode_info *cii;
  490. if (!inode)
  491. return 1;
  492. lock_kernel();
  493. if (coda_isroot(inode))
  494. goto out;
  495. if (is_bad_inode(inode))
  496. goto bad;
  497. cii = ITOC(de->d_inode);
  498. if (!(cii->c_flags & (C_PURGE | C_FLUSH)))
  499. goto out;
  500. shrink_dcache_parent(de);
  501. /* propagate for a flush */
  502. if (cii->c_flags & C_FLUSH)
  503. coda_flag_inode_children(inode, C_FLUSH);
  504. if (atomic_read(&de->d_count) > 1)
  505. /* pretend it's valid, but don't change the flags */
  506. goto out;
  507. /* clear the flags. */
  508. cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH);
  509. bad:
  510. unlock_kernel();
  511. return 0;
  512. out:
  513. unlock_kernel();
  514. return 1;
  515. }
  516. /*
  517. * This is the callback from dput() when d_count is going to 0.
  518. * We use this to unhash dentries with bad inodes.
  519. */
  520. static int coda_dentry_delete(struct dentry * dentry)
  521. {
  522. int flags;
  523. if (!dentry->d_inode)
  524. return 0;
  525. flags = (ITOC(dentry->d_inode)->c_flags) & C_PURGE;
  526. if (is_bad_inode(dentry->d_inode) || flags) {
  527. return 1;
  528. }
  529. return 0;
  530. }
  531. /*
  532. * This is called when we want to check if the inode has
  533. * changed on the server. Coda makes this easy since the
  534. * cache manager Venus issues a downcall to the kernel when this
  535. * happens
  536. */
  537. int coda_revalidate_inode(struct dentry *dentry)
  538. {
  539. struct coda_vattr attr;
  540. int error = 0;
  541. int old_mode;
  542. ino_t old_ino;
  543. struct inode *inode = dentry->d_inode;
  544. struct coda_inode_info *cii = ITOC(inode);
  545. lock_kernel();
  546. if ( !cii->c_flags )
  547. goto ok;
  548. if (cii->c_flags & (C_VATTR | C_PURGE | C_FLUSH)) {
  549. error = venus_getattr(inode->i_sb, &(cii->c_fid), &attr);
  550. if ( error )
  551. goto return_bad;
  552. /* this inode may be lost if:
  553. - it's ino changed
  554. - type changes must be permitted for repair and
  555. missing mount points.
  556. */
  557. old_mode = inode->i_mode;
  558. old_ino = inode->i_ino;
  559. coda_vattr_to_iattr(inode, &attr);
  560. if ((old_mode & S_IFMT) != (inode->i_mode & S_IFMT)) {
  561. printk("Coda: inode %ld, fid %s changed type!\n",
  562. inode->i_ino, coda_f2s(&(cii->c_fid)));
  563. }
  564. /* the following can happen when a local fid is replaced
  565. with a global one, here we lose and declare the inode bad */
  566. if (inode->i_ino != old_ino)
  567. goto return_bad;
  568. coda_flag_inode_children(inode, C_FLUSH);
  569. cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH);
  570. }
  571. ok:
  572. unlock_kernel();
  573. return 0;
  574. return_bad:
  575. unlock_kernel();
  576. return -EIO;
  577. }