namei_msdos.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. /*
  2. * linux/fs/msdos/namei.c
  3. *
  4. * Written 1992,1993 by Werner Almesberger
  5. * Hidden files 1995 by Albert Cahalan <albert@ccs.neu.edu> <adc@coe.neu.edu>
  6. * Rewritten for constant inumbers 1999 by Al Viro
  7. */
  8. #include <linux/module.h>
  9. #include <linux/time.h>
  10. #include <linux/buffer_head.h>
  11. #include "fat.h"
  12. /* Characters that are undesirable in an MS-DOS file name */
  13. static unsigned char bad_chars[] = "*?<>|\"";
  14. static unsigned char bad_if_strict[] = "+=,; ";
  15. /***** Formats an MS-DOS file name. Rejects invalid names. */
  16. static int msdos_format_name(const unsigned char *name, int len,
  17. unsigned char *res, struct fat_mount_options *opts)
  18. /*
  19. * name is the proposed name, len is its length, res is
  20. * the resulting name, opts->name_check is either (r)elaxed,
  21. * (n)ormal or (s)trict, opts->dotsOK allows dots at the
  22. * beginning of name (for hidden files)
  23. */
  24. {
  25. unsigned char *walk;
  26. unsigned char c;
  27. int space;
  28. if (name[0] == '.') { /* dotfile because . and .. already done */
  29. if (opts->dotsOK) {
  30. /* Get rid of dot - test for it elsewhere */
  31. name++;
  32. len--;
  33. } else
  34. return -EINVAL;
  35. }
  36. /*
  37. * disallow names that _really_ start with a dot
  38. */
  39. space = 1;
  40. c = 0;
  41. for (walk = res; len && walk - res < 8; walk++) {
  42. c = *name++;
  43. len--;
  44. if (opts->name_check != 'r' && strchr(bad_chars, c))
  45. return -EINVAL;
  46. if (opts->name_check == 's' && strchr(bad_if_strict, c))
  47. return -EINVAL;
  48. if (c >= 'A' && c <= 'Z' && opts->name_check == 's')
  49. return -EINVAL;
  50. if (c < ' ' || c == ':' || c == '\\')
  51. return -EINVAL;
  52. /*
  53. * 0xE5 is legal as a first character, but we must substitute
  54. * 0x05 because 0xE5 marks deleted files. Yes, DOS really
  55. * does this.
  56. * It seems that Microsoft hacked DOS to support non-US
  57. * characters after the 0xE5 character was already in use to
  58. * mark deleted files.
  59. */
  60. if ((res == walk) && (c == 0xE5))
  61. c = 0x05;
  62. if (c == '.')
  63. break;
  64. space = (c == ' ');
  65. *walk = (!opts->nocase && c >= 'a' && c <= 'z') ? c - 32 : c;
  66. }
  67. if (space)
  68. return -EINVAL;
  69. if (opts->name_check == 's' && len && c != '.') {
  70. c = *name++;
  71. len--;
  72. if (c != '.')
  73. return -EINVAL;
  74. }
  75. while (c != '.' && len--)
  76. c = *name++;
  77. if (c == '.') {
  78. while (walk - res < 8)
  79. *walk++ = ' ';
  80. while (len > 0 && walk - res < MSDOS_NAME) {
  81. c = *name++;
  82. len--;
  83. if (opts->name_check != 'r' && strchr(bad_chars, c))
  84. return -EINVAL;
  85. if (opts->name_check == 's' &&
  86. strchr(bad_if_strict, c))
  87. return -EINVAL;
  88. if (c < ' ' || c == ':' || c == '\\')
  89. return -EINVAL;
  90. if (c == '.') {
  91. if (opts->name_check == 's')
  92. return -EINVAL;
  93. break;
  94. }
  95. if (c >= 'A' && c <= 'Z' && opts->name_check == 's')
  96. return -EINVAL;
  97. space = c == ' ';
  98. if (!opts->nocase && c >= 'a' && c <= 'z')
  99. *walk++ = c - 32;
  100. else
  101. *walk++ = c;
  102. }
  103. if (space)
  104. return -EINVAL;
  105. if (opts->name_check == 's' && len)
  106. return -EINVAL;
  107. }
  108. while (walk - res < MSDOS_NAME)
  109. *walk++ = ' ';
  110. return 0;
  111. }
  112. /***** Locates a directory entry. Uses unformatted name. */
  113. static int msdos_find(struct inode *dir, const unsigned char *name, int len,
  114. struct fat_slot_info *sinfo)
  115. {
  116. struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
  117. unsigned char msdos_name[MSDOS_NAME];
  118. int err;
  119. err = msdos_format_name(name, len, msdos_name, &sbi->options);
  120. if (err)
  121. return -ENOENT;
  122. err = fat_scan(dir, msdos_name, sinfo);
  123. if (!err && sbi->options.dotsOK) {
  124. if (name[0] == '.') {
  125. if (!(sinfo->de->attr & ATTR_HIDDEN))
  126. err = -ENOENT;
  127. } else {
  128. if (sinfo->de->attr & ATTR_HIDDEN)
  129. err = -ENOENT;
  130. }
  131. if (err)
  132. brelse(sinfo->bh);
  133. }
  134. return err;
  135. }
  136. /*
  137. * Compute the hash for the msdos name corresponding to the dentry.
  138. * Note: if the name is invalid, we leave the hash code unchanged so
  139. * that the existing dentry can be used. The msdos fs routines will
  140. * return ENOENT or EINVAL as appropriate.
  141. */
  142. static int msdos_hash(const struct dentry *dentry, const struct inode *inode,
  143. struct qstr *qstr)
  144. {
  145. struct fat_mount_options *options = &MSDOS_SB(dentry->d_sb)->options;
  146. unsigned char msdos_name[MSDOS_NAME];
  147. int error;
  148. error = msdos_format_name(qstr->name, qstr->len, msdos_name, options);
  149. if (!error)
  150. qstr->hash = full_name_hash(msdos_name, MSDOS_NAME);
  151. return 0;
  152. }
  153. /*
  154. * Compare two msdos names. If either of the names are invalid,
  155. * we fall back to doing the standard name comparison.
  156. */
  157. static int msdos_cmp(const struct dentry *parent, const struct inode *pinode,
  158. const struct dentry *dentry, const struct inode *inode,
  159. unsigned int len, const char *str, const struct qstr *name)
  160. {
  161. struct fat_mount_options *options = &MSDOS_SB(parent->d_sb)->options;
  162. unsigned char a_msdos_name[MSDOS_NAME], b_msdos_name[MSDOS_NAME];
  163. int error;
  164. error = msdos_format_name(name->name, name->len, a_msdos_name, options);
  165. if (error)
  166. goto old_compare;
  167. error = msdos_format_name(str, len, b_msdos_name, options);
  168. if (error)
  169. goto old_compare;
  170. error = memcmp(a_msdos_name, b_msdos_name, MSDOS_NAME);
  171. out:
  172. return error;
  173. old_compare:
  174. error = 1;
  175. if (name->len == len)
  176. error = memcmp(name->name, str, len);
  177. goto out;
  178. }
  179. static const struct dentry_operations msdos_dentry_operations = {
  180. .d_hash = msdos_hash,
  181. .d_compare = msdos_cmp,
  182. };
  183. /*
  184. * AV. Wrappers for FAT sb operations. Is it wise?
  185. */
  186. /***** Get inode using directory and name */
  187. static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
  188. struct nameidata *nd)
  189. {
  190. struct super_block *sb = dir->i_sb;
  191. struct fat_slot_info sinfo;
  192. struct inode *inode;
  193. int err;
  194. lock_super(sb);
  195. err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
  196. switch (err) {
  197. case -ENOENT:
  198. inode = NULL;
  199. break;
  200. case 0:
  201. inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
  202. brelse(sinfo.bh);
  203. break;
  204. default:
  205. inode = ERR_PTR(err);
  206. }
  207. unlock_super(sb);
  208. return d_splice_alias(inode, dentry);
  209. }
  210. /***** Creates a directory entry (name is already formatted). */
  211. static int msdos_add_entry(struct inode *dir, const unsigned char *name,
  212. int is_dir, int is_hid, int cluster,
  213. struct timespec *ts, struct fat_slot_info *sinfo)
  214. {
  215. struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
  216. struct msdos_dir_entry de;
  217. __le16 time, date;
  218. int err;
  219. memcpy(de.name, name, MSDOS_NAME);
  220. de.attr = is_dir ? ATTR_DIR : ATTR_ARCH;
  221. if (is_hid)
  222. de.attr |= ATTR_HIDDEN;
  223. de.lcase = 0;
  224. fat_time_unix2fat(sbi, ts, &time, &date, NULL);
  225. de.cdate = de.adate = 0;
  226. de.ctime = 0;
  227. de.ctime_cs = 0;
  228. de.time = time;
  229. de.date = date;
  230. fat_set_start(&de, cluster);
  231. de.size = 0;
  232. err = fat_add_entries(dir, &de, 1, sinfo);
  233. if (err)
  234. return err;
  235. dir->i_ctime = dir->i_mtime = *ts;
  236. if (IS_DIRSYNC(dir))
  237. (void)fat_sync_inode(dir);
  238. else
  239. mark_inode_dirty(dir);
  240. return 0;
  241. }
  242. /***** Create a file */
  243. static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
  244. struct nameidata *nd)
  245. {
  246. struct super_block *sb = dir->i_sb;
  247. struct inode *inode = NULL;
  248. struct fat_slot_info sinfo;
  249. struct timespec ts;
  250. unsigned char msdos_name[MSDOS_NAME];
  251. int err, is_hid;
  252. lock_super(sb);
  253. err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
  254. msdos_name, &MSDOS_SB(sb)->options);
  255. if (err)
  256. goto out;
  257. is_hid = (dentry->d_name.name[0] == '.') && (msdos_name[0] != '.');
  258. /* Have to do it due to foo vs. .foo conflicts */
  259. if (!fat_scan(dir, msdos_name, &sinfo)) {
  260. brelse(sinfo.bh);
  261. err = -EINVAL;
  262. goto out;
  263. }
  264. ts = CURRENT_TIME_SEC;
  265. err = msdos_add_entry(dir, msdos_name, 0, is_hid, 0, &ts, &sinfo);
  266. if (err)
  267. goto out;
  268. inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
  269. brelse(sinfo.bh);
  270. if (IS_ERR(inode)) {
  271. err = PTR_ERR(inode);
  272. goto out;
  273. }
  274. inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
  275. /* timestamp is already written, so mark_inode_dirty() is unneeded. */
  276. d_instantiate(dentry, inode);
  277. out:
  278. unlock_super(sb);
  279. if (!err)
  280. err = fat_flush_inodes(sb, dir, inode);
  281. return err;
  282. }
  283. /***** Remove a directory */
  284. static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
  285. {
  286. struct super_block *sb = dir->i_sb;
  287. struct inode *inode = dentry->d_inode;
  288. struct fat_slot_info sinfo;
  289. int err;
  290. lock_super(sb);
  291. /*
  292. * Check whether the directory is not in use, then check
  293. * whether it is empty.
  294. */
  295. err = fat_dir_empty(inode);
  296. if (err)
  297. goto out;
  298. err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
  299. if (err)
  300. goto out;
  301. err = fat_remove_entries(dir, &sinfo); /* and releases bh */
  302. if (err)
  303. goto out;
  304. drop_nlink(dir);
  305. clear_nlink(inode);
  306. inode->i_ctime = CURRENT_TIME_SEC;
  307. fat_detach(inode);
  308. out:
  309. unlock_super(sb);
  310. if (!err)
  311. err = fat_flush_inodes(sb, dir, inode);
  312. return err;
  313. }
  314. /***** Make a directory */
  315. static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
  316. {
  317. struct super_block *sb = dir->i_sb;
  318. struct fat_slot_info sinfo;
  319. struct inode *inode;
  320. unsigned char msdos_name[MSDOS_NAME];
  321. struct timespec ts;
  322. int err, is_hid, cluster;
  323. lock_super(sb);
  324. err = msdos_format_name(dentry->d_name.name, dentry->d_name.len,
  325. msdos_name, &MSDOS_SB(sb)->options);
  326. if (err)
  327. goto out;
  328. is_hid = (dentry->d_name.name[0] == '.') && (msdos_name[0] != '.');
  329. /* foo vs .foo situation */
  330. if (!fat_scan(dir, msdos_name, &sinfo)) {
  331. brelse(sinfo.bh);
  332. err = -EINVAL;
  333. goto out;
  334. }
  335. ts = CURRENT_TIME_SEC;
  336. cluster = fat_alloc_new_dir(dir, &ts);
  337. if (cluster < 0) {
  338. err = cluster;
  339. goto out;
  340. }
  341. err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &ts, &sinfo);
  342. if (err)
  343. goto out_free;
  344. inc_nlink(dir);
  345. inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
  346. brelse(sinfo.bh);
  347. if (IS_ERR(inode)) {
  348. err = PTR_ERR(inode);
  349. /* the directory was completed, just return a error */
  350. goto out;
  351. }
  352. set_nlink(inode, 2);
  353. inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
  354. /* timestamp is already written, so mark_inode_dirty() is unneeded. */
  355. d_instantiate(dentry, inode);
  356. unlock_super(sb);
  357. fat_flush_inodes(sb, dir, inode);
  358. return 0;
  359. out_free:
  360. fat_free_clusters(dir, cluster);
  361. out:
  362. unlock_super(sb);
  363. return err;
  364. }
  365. /***** Unlink a file */
  366. static int msdos_unlink(struct inode *dir, struct dentry *dentry)
  367. {
  368. struct inode *inode = dentry->d_inode;
  369. struct super_block *sb= inode->i_sb;
  370. struct fat_slot_info sinfo;
  371. int err;
  372. lock_super(sb);
  373. err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
  374. if (err)
  375. goto out;
  376. err = fat_remove_entries(dir, &sinfo); /* and releases bh */
  377. if (err)
  378. goto out;
  379. clear_nlink(inode);
  380. inode->i_ctime = CURRENT_TIME_SEC;
  381. fat_detach(inode);
  382. out:
  383. unlock_super(sb);
  384. if (!err)
  385. err = fat_flush_inodes(sb, dir, inode);
  386. return err;
  387. }
  388. static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
  389. struct dentry *old_dentry,
  390. struct inode *new_dir, unsigned char *new_name,
  391. struct dentry *new_dentry, int is_hid)
  392. {
  393. struct buffer_head *dotdot_bh;
  394. struct msdos_dir_entry *dotdot_de;
  395. struct inode *old_inode, *new_inode;
  396. struct fat_slot_info old_sinfo, sinfo;
  397. struct timespec ts;
  398. loff_t dotdot_i_pos, new_i_pos;
  399. int err, old_attrs, is_dir, update_dotdot, corrupt = 0;
  400. old_sinfo.bh = sinfo.bh = dotdot_bh = NULL;
  401. old_inode = old_dentry->d_inode;
  402. new_inode = new_dentry->d_inode;
  403. err = fat_scan(old_dir, old_name, &old_sinfo);
  404. if (err) {
  405. err = -EIO;
  406. goto out;
  407. }
  408. is_dir = S_ISDIR(old_inode->i_mode);
  409. update_dotdot = (is_dir && old_dir != new_dir);
  410. if (update_dotdot) {
  411. if (fat_get_dotdot_entry(old_inode, &dotdot_bh, &dotdot_de,
  412. &dotdot_i_pos) < 0) {
  413. err = -EIO;
  414. goto out;
  415. }
  416. }
  417. old_attrs = MSDOS_I(old_inode)->i_attrs;
  418. err = fat_scan(new_dir, new_name, &sinfo);
  419. if (!err) {
  420. if (!new_inode) {
  421. /* "foo" -> ".foo" case. just change the ATTR_HIDDEN */
  422. if (sinfo.de != old_sinfo.de) {
  423. err = -EINVAL;
  424. goto out;
  425. }
  426. if (is_hid)
  427. MSDOS_I(old_inode)->i_attrs |= ATTR_HIDDEN;
  428. else
  429. MSDOS_I(old_inode)->i_attrs &= ~ATTR_HIDDEN;
  430. if (IS_DIRSYNC(old_dir)) {
  431. err = fat_sync_inode(old_inode);
  432. if (err) {
  433. MSDOS_I(old_inode)->i_attrs = old_attrs;
  434. goto out;
  435. }
  436. } else
  437. mark_inode_dirty(old_inode);
  438. old_dir->i_version++;
  439. old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC;
  440. if (IS_DIRSYNC(old_dir))
  441. (void)fat_sync_inode(old_dir);
  442. else
  443. mark_inode_dirty(old_dir);
  444. goto out;
  445. }
  446. }
  447. ts = CURRENT_TIME_SEC;
  448. if (new_inode) {
  449. if (err)
  450. goto out;
  451. if (is_dir) {
  452. err = fat_dir_empty(new_inode);
  453. if (err)
  454. goto out;
  455. }
  456. new_i_pos = MSDOS_I(new_inode)->i_pos;
  457. fat_detach(new_inode);
  458. } else {
  459. err = msdos_add_entry(new_dir, new_name, is_dir, is_hid, 0,
  460. &ts, &sinfo);
  461. if (err)
  462. goto out;
  463. new_i_pos = sinfo.i_pos;
  464. }
  465. new_dir->i_version++;
  466. fat_detach(old_inode);
  467. fat_attach(old_inode, new_i_pos);
  468. if (is_hid)
  469. MSDOS_I(old_inode)->i_attrs |= ATTR_HIDDEN;
  470. else
  471. MSDOS_I(old_inode)->i_attrs &= ~ATTR_HIDDEN;
  472. if (IS_DIRSYNC(new_dir)) {
  473. err = fat_sync_inode(old_inode);
  474. if (err)
  475. goto error_inode;
  476. } else
  477. mark_inode_dirty(old_inode);
  478. if (update_dotdot) {
  479. fat_set_start(dotdot_de, MSDOS_I(new_dir)->i_logstart);
  480. mark_buffer_dirty_inode(dotdot_bh, old_inode);
  481. if (IS_DIRSYNC(new_dir)) {
  482. err = sync_dirty_buffer(dotdot_bh);
  483. if (err)
  484. goto error_dotdot;
  485. }
  486. drop_nlink(old_dir);
  487. if (!new_inode)
  488. inc_nlink(new_dir);
  489. }
  490. err = fat_remove_entries(old_dir, &old_sinfo); /* and releases bh */
  491. old_sinfo.bh = NULL;
  492. if (err)
  493. goto error_dotdot;
  494. old_dir->i_version++;
  495. old_dir->i_ctime = old_dir->i_mtime = ts;
  496. if (IS_DIRSYNC(old_dir))
  497. (void)fat_sync_inode(old_dir);
  498. else
  499. mark_inode_dirty(old_dir);
  500. if (new_inode) {
  501. drop_nlink(new_inode);
  502. if (is_dir)
  503. drop_nlink(new_inode);
  504. new_inode->i_ctime = ts;
  505. }
  506. out:
  507. brelse(sinfo.bh);
  508. brelse(dotdot_bh);
  509. brelse(old_sinfo.bh);
  510. return err;
  511. error_dotdot:
  512. /* data cluster is shared, serious corruption */
  513. corrupt = 1;
  514. if (update_dotdot) {
  515. fat_set_start(dotdot_de, MSDOS_I(old_dir)->i_logstart);
  516. mark_buffer_dirty_inode(dotdot_bh, old_inode);
  517. corrupt |= sync_dirty_buffer(dotdot_bh);
  518. }
  519. error_inode:
  520. fat_detach(old_inode);
  521. fat_attach(old_inode, old_sinfo.i_pos);
  522. MSDOS_I(old_inode)->i_attrs = old_attrs;
  523. if (new_inode) {
  524. fat_attach(new_inode, new_i_pos);
  525. if (corrupt)
  526. corrupt |= fat_sync_inode(new_inode);
  527. } else {
  528. /*
  529. * If new entry was not sharing the data cluster, it
  530. * shouldn't be serious corruption.
  531. */
  532. int err2 = fat_remove_entries(new_dir, &sinfo);
  533. if (corrupt)
  534. corrupt |= err2;
  535. sinfo.bh = NULL;
  536. }
  537. if (corrupt < 0) {
  538. fat_fs_error(new_dir->i_sb,
  539. "%s: Filesystem corrupted (i_pos %lld)",
  540. __func__, sinfo.i_pos);
  541. }
  542. goto out;
  543. }
  544. /***** Rename, a wrapper for rename_same_dir & rename_diff_dir */
  545. static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry,
  546. struct inode *new_dir, struct dentry *new_dentry)
  547. {
  548. struct super_block *sb = old_dir->i_sb;
  549. unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME];
  550. int err, is_hid;
  551. lock_super(sb);
  552. err = msdos_format_name(old_dentry->d_name.name,
  553. old_dentry->d_name.len, old_msdos_name,
  554. &MSDOS_SB(old_dir->i_sb)->options);
  555. if (err)
  556. goto out;
  557. err = msdos_format_name(new_dentry->d_name.name,
  558. new_dentry->d_name.len, new_msdos_name,
  559. &MSDOS_SB(new_dir->i_sb)->options);
  560. if (err)
  561. goto out;
  562. is_hid =
  563. (new_dentry->d_name.name[0] == '.') && (new_msdos_name[0] != '.');
  564. err = do_msdos_rename(old_dir, old_msdos_name, old_dentry,
  565. new_dir, new_msdos_name, new_dentry, is_hid);
  566. out:
  567. unlock_super(sb);
  568. if (!err)
  569. err = fat_flush_inodes(sb, old_dir, new_dir);
  570. return err;
  571. }
  572. static const struct inode_operations msdos_dir_inode_operations = {
  573. .create = msdos_create,
  574. .lookup = msdos_lookup,
  575. .unlink = msdos_unlink,
  576. .mkdir = msdos_mkdir,
  577. .rmdir = msdos_rmdir,
  578. .rename = msdos_rename,
  579. .setattr = fat_setattr,
  580. .getattr = fat_getattr,
  581. };
  582. static void setup(struct super_block *sb)
  583. {
  584. MSDOS_SB(sb)->dir_ops = &msdos_dir_inode_operations;
  585. sb->s_d_op = &msdos_dentry_operations;
  586. sb->s_flags |= MS_NOATIME;
  587. }
  588. static int msdos_fill_super(struct super_block *sb, void *data, int silent)
  589. {
  590. return fat_fill_super(sb, data, silent, 0, setup);
  591. }
  592. static struct dentry *msdos_mount(struct file_system_type *fs_type,
  593. int flags, const char *dev_name,
  594. void *data)
  595. {
  596. return mount_bdev(fs_type, flags, dev_name, data, msdos_fill_super);
  597. }
  598. static struct file_system_type msdos_fs_type = {
  599. .owner = THIS_MODULE,
  600. .name = "msdos",
  601. .mount = msdos_mount,
  602. .kill_sb = kill_block_super,
  603. .fs_flags = FS_REQUIRES_DEV,
  604. };
  605. MODULE_ALIAS_FS("msdos");
  606. static int __init init_msdos_fs(void)
  607. {
  608. return register_filesystem(&msdos_fs_type);
  609. }
  610. static void __exit exit_msdos_fs(void)
  611. {
  612. unregister_filesystem(&msdos_fs_type);
  613. }
  614. MODULE_LICENSE("GPL");
  615. MODULE_AUTHOR("Werner Almesberger");
  616. MODULE_DESCRIPTION("MS-DOS filesystem support");
  617. module_init(init_msdos_fs)
  618. module_exit(exit_msdos_fs)