hppfs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /*
  2. * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Licensed under the GPL
  4. */
  5. #include <linux/ctype.h>
  6. #include <linux/dcache.h>
  7. #include <linux/file.h>
  8. #include <linux/fs.h>
  9. #include <linux/init.h>
  10. #include <linux/kernel.h>
  11. #include <linux/list.h>
  12. #include <linux/module.h>
  13. #include <linux/mount.h>
  14. #include <linux/slab.h>
  15. #include <linux/statfs.h>
  16. #include <linux/types.h>
  17. #include <asm/uaccess.h>
  18. #include "os.h"
  19. static struct inode *get_inode(struct super_block *, struct dentry *);
  20. struct hppfs_data {
  21. struct list_head list;
  22. char contents[PAGE_SIZE - sizeof(struct list_head)];
  23. };
  24. struct hppfs_private {
  25. struct file *proc_file;
  26. int host_fd;
  27. loff_t len;
  28. struct hppfs_data *contents;
  29. };
  30. struct hppfs_inode_info {
  31. struct dentry *proc_dentry;
  32. struct inode vfs_inode;
  33. };
  34. static inline struct hppfs_inode_info *HPPFS_I(struct inode *inode)
  35. {
  36. return container_of(inode, struct hppfs_inode_info, vfs_inode);
  37. }
  38. #define HPPFS_SUPER_MAGIC 0xb00000ee
  39. static const struct super_operations hppfs_sbops;
  40. static int is_pid(struct dentry *dentry)
  41. {
  42. struct super_block *sb;
  43. int i;
  44. sb = dentry->d_sb;
  45. if (dentry->d_parent != sb->s_root)
  46. return 0;
  47. for (i = 0; i < dentry->d_name.len; i++) {
  48. if (!isdigit(dentry->d_name.name[i]))
  49. return 0;
  50. }
  51. return 1;
  52. }
  53. static char *dentry_name(struct dentry *dentry, int extra)
  54. {
  55. struct dentry *parent;
  56. char *root, *name;
  57. const char *seg_name;
  58. int len, seg_len;
  59. len = 0;
  60. parent = dentry;
  61. while (parent->d_parent != parent) {
  62. if (is_pid(parent))
  63. len += strlen("pid") + 1;
  64. else len += parent->d_name.len + 1;
  65. parent = parent->d_parent;
  66. }
  67. root = "proc";
  68. len += strlen(root);
  69. name = kmalloc(len + extra + 1, GFP_KERNEL);
  70. if (name == NULL)
  71. return NULL;
  72. name[len] = '\0';
  73. parent = dentry;
  74. while (parent->d_parent != parent) {
  75. if (is_pid(parent)) {
  76. seg_name = "pid";
  77. seg_len = strlen("pid");
  78. }
  79. else {
  80. seg_name = parent->d_name.name;
  81. seg_len = parent->d_name.len;
  82. }
  83. len -= seg_len + 1;
  84. name[len] = '/';
  85. strncpy(&name[len + 1], seg_name, seg_len);
  86. parent = parent->d_parent;
  87. }
  88. strncpy(name, root, strlen(root));
  89. return name;
  90. }
  91. static int file_removed(struct dentry *dentry, const char *file)
  92. {
  93. char *host_file;
  94. int extra, fd;
  95. extra = 0;
  96. if (file != NULL)
  97. extra += strlen(file) + 1;
  98. host_file = dentry_name(dentry, extra + strlen("/remove"));
  99. if (host_file == NULL) {
  100. printk(KERN_ERR "file_removed : allocation failed\n");
  101. return -ENOMEM;
  102. }
  103. if (file != NULL) {
  104. strcat(host_file, "/");
  105. strcat(host_file, file);
  106. }
  107. strcat(host_file, "/remove");
  108. fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
  109. kfree(host_file);
  110. if (fd > 0) {
  111. os_close_file(fd);
  112. return 1;
  113. }
  114. return 0;
  115. }
  116. static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
  117. struct nameidata *nd)
  118. {
  119. struct dentry *proc_dentry, *new, *parent;
  120. struct inode *inode;
  121. int err, deleted;
  122. deleted = file_removed(dentry, NULL);
  123. if (deleted < 0)
  124. return ERR_PTR(deleted);
  125. else if (deleted)
  126. return ERR_PTR(-ENOENT);
  127. err = -ENOMEM;
  128. parent = HPPFS_I(ino)->proc_dentry;
  129. mutex_lock(&parent->d_inode->i_mutex);
  130. proc_dentry = d_lookup(parent, &dentry->d_name);
  131. if (proc_dentry == NULL) {
  132. proc_dentry = d_alloc(parent, &dentry->d_name);
  133. if (proc_dentry == NULL) {
  134. mutex_unlock(&parent->d_inode->i_mutex);
  135. goto out;
  136. }
  137. new = (*parent->d_inode->i_op->lookup)(parent->d_inode,
  138. proc_dentry, NULL);
  139. if (new) {
  140. dput(proc_dentry);
  141. proc_dentry = new;
  142. }
  143. }
  144. mutex_unlock(&parent->d_inode->i_mutex);
  145. if (IS_ERR(proc_dentry))
  146. return proc_dentry;
  147. err = -ENOMEM;
  148. inode = get_inode(ino->i_sb, proc_dentry);
  149. if (!inode)
  150. goto out_dput;
  151. d_add(dentry, inode);
  152. return NULL;
  153. out_dput:
  154. dput(proc_dentry);
  155. out:
  156. return ERR_PTR(err);
  157. }
  158. static const struct inode_operations hppfs_file_iops = {
  159. };
  160. static ssize_t read_proc(struct file *file, char __user *buf, ssize_t count,
  161. loff_t *ppos, int is_user)
  162. {
  163. ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
  164. ssize_t n;
  165. read = file->f_path.dentry->d_inode->i_fop->read;
  166. if (!is_user)
  167. set_fs(KERNEL_DS);
  168. n = (*read)(file, buf, count, &file->f_pos);
  169. if (!is_user)
  170. set_fs(USER_DS);
  171. if (ppos)
  172. *ppos = file->f_pos;
  173. return n;
  174. }
  175. static ssize_t hppfs_read_file(int fd, char __user *buf, ssize_t count)
  176. {
  177. ssize_t n;
  178. int cur, err;
  179. char *new_buf;
  180. n = -ENOMEM;
  181. new_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
  182. if (new_buf == NULL) {
  183. printk(KERN_ERR "hppfs_read_file : kmalloc failed\n");
  184. goto out;
  185. }
  186. n = 0;
  187. while (count > 0) {
  188. cur = min_t(ssize_t, count, PAGE_SIZE);
  189. err = os_read_file(fd, new_buf, cur);
  190. if (err < 0) {
  191. printk(KERN_ERR "hppfs_read : read failed, "
  192. "errno = %d\n", err);
  193. n = err;
  194. goto out_free;
  195. } else if (err == 0)
  196. break;
  197. if (copy_to_user(buf, new_buf, err)) {
  198. n = -EFAULT;
  199. goto out_free;
  200. }
  201. n += err;
  202. count -= err;
  203. }
  204. out_free:
  205. kfree(new_buf);
  206. out:
  207. return n;
  208. }
  209. static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count,
  210. loff_t *ppos)
  211. {
  212. struct hppfs_private *hppfs = file->private_data;
  213. struct hppfs_data *data;
  214. loff_t off;
  215. int err;
  216. if (hppfs->contents != NULL) {
  217. int rem;
  218. if (*ppos >= hppfs->len)
  219. return 0;
  220. data = hppfs->contents;
  221. off = *ppos;
  222. while (off >= sizeof(data->contents)) {
  223. data = list_entry(data->list.next, struct hppfs_data,
  224. list);
  225. off -= sizeof(data->contents);
  226. }
  227. if (off + count > hppfs->len)
  228. count = hppfs->len - off;
  229. rem = copy_to_user(buf, &data->contents[off], count);
  230. *ppos += count - rem;
  231. if (rem > 0)
  232. return -EFAULT;
  233. } else if (hppfs->host_fd != -1) {
  234. err = os_seek_file(hppfs->host_fd, *ppos);
  235. if (err) {
  236. printk(KERN_ERR "hppfs_read : seek failed, "
  237. "errno = %d\n", err);
  238. return err;
  239. }
  240. count = hppfs_read_file(hppfs->host_fd, buf, count);
  241. if (count > 0)
  242. *ppos += count;
  243. }
  244. else count = read_proc(hppfs->proc_file, buf, count, ppos, 1);
  245. return count;
  246. }
  247. static ssize_t hppfs_write(struct file *file, const char __user *buf,
  248. size_t len, loff_t *ppos)
  249. {
  250. struct hppfs_private *data = file->private_data;
  251. struct file *proc_file = data->proc_file;
  252. ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
  253. write = proc_file->f_path.dentry->d_inode->i_fop->write;
  254. return (*write)(proc_file, buf, len, ppos);
  255. }
  256. static int open_host_sock(char *host_file, int *filter_out)
  257. {
  258. char *end;
  259. int fd;
  260. end = &host_file[strlen(host_file)];
  261. strcpy(end, "/rw");
  262. *filter_out = 1;
  263. fd = os_connect_socket(host_file);
  264. if (fd > 0)
  265. return fd;
  266. strcpy(end, "/r");
  267. *filter_out = 0;
  268. fd = os_connect_socket(host_file);
  269. return fd;
  270. }
  271. static void free_contents(struct hppfs_data *head)
  272. {
  273. struct hppfs_data *data;
  274. struct list_head *ele, *next;
  275. if (head == NULL)
  276. return;
  277. list_for_each_safe(ele, next, &head->list) {
  278. data = list_entry(ele, struct hppfs_data, list);
  279. kfree(data);
  280. }
  281. kfree(head);
  282. }
  283. static struct hppfs_data *hppfs_get_data(int fd, int filter,
  284. struct file *proc_file,
  285. struct file *hppfs_file,
  286. loff_t *size_out)
  287. {
  288. struct hppfs_data *data, *new, *head;
  289. int n, err;
  290. err = -ENOMEM;
  291. data = kmalloc(sizeof(*data), GFP_KERNEL);
  292. if (data == NULL) {
  293. printk(KERN_ERR "hppfs_get_data : head allocation failed\n");
  294. goto failed;
  295. }
  296. INIT_LIST_HEAD(&data->list);
  297. head = data;
  298. *size_out = 0;
  299. if (filter) {
  300. while ((n = read_proc(proc_file, data->contents,
  301. sizeof(data->contents), NULL, 0)) > 0)
  302. os_write_file(fd, data->contents, n);
  303. err = os_shutdown_socket(fd, 0, 1);
  304. if (err) {
  305. printk(KERN_ERR "hppfs_get_data : failed to shut down "
  306. "socket\n");
  307. goto failed_free;
  308. }
  309. }
  310. while (1) {
  311. n = os_read_file(fd, data->contents, sizeof(data->contents));
  312. if (n < 0) {
  313. err = n;
  314. printk(KERN_ERR "hppfs_get_data : read failed, "
  315. "errno = %d\n", err);
  316. goto failed_free;
  317. } else if (n == 0)
  318. break;
  319. *size_out += n;
  320. if (n < sizeof(data->contents))
  321. break;
  322. new = kmalloc(sizeof(*data), GFP_KERNEL);
  323. if (new == 0) {
  324. printk(KERN_ERR "hppfs_get_data : data allocation "
  325. "failed\n");
  326. err = -ENOMEM;
  327. goto failed_free;
  328. }
  329. INIT_LIST_HEAD(&new->list);
  330. list_add(&new->list, &data->list);
  331. data = new;
  332. }
  333. return head;
  334. failed_free:
  335. free_contents(head);
  336. failed:
  337. return ERR_PTR(err);
  338. }
  339. static struct hppfs_private *hppfs_data(void)
  340. {
  341. struct hppfs_private *data;
  342. data = kmalloc(sizeof(*data), GFP_KERNEL);
  343. if (data == NULL)
  344. return data;
  345. *data = ((struct hppfs_private ) { .host_fd = -1,
  346. .len = -1,
  347. .contents = NULL } );
  348. return data;
  349. }
  350. static int file_mode(int fmode)
  351. {
  352. if (fmode == (FMODE_READ | FMODE_WRITE))
  353. return O_RDWR;
  354. if (fmode == FMODE_READ)
  355. return O_RDONLY;
  356. if (fmode == FMODE_WRITE)
  357. return O_WRONLY;
  358. return 0;
  359. }
  360. static int hppfs_open(struct inode *inode, struct file *file)
  361. {
  362. const struct cred *cred = current_cred();
  363. struct hppfs_private *data;
  364. struct vfsmount *proc_mnt;
  365. struct dentry *proc_dentry;
  366. char *host_file;
  367. int err, fd, type, filter;
  368. err = -ENOMEM;
  369. data = hppfs_data();
  370. if (data == NULL)
  371. goto out;
  372. host_file = dentry_name(file->f_path.dentry, strlen("/rw"));
  373. if (host_file == NULL)
  374. goto out_free2;
  375. proc_dentry = HPPFS_I(inode)->proc_dentry;
  376. proc_mnt = inode->i_sb->s_fs_info;
  377. /* XXX This isn't closed anywhere */
  378. data->proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt),
  379. file_mode(file->f_mode), cred);
  380. err = PTR_ERR(data->proc_file);
  381. if (IS_ERR(data->proc_file))
  382. goto out_free1;
  383. type = os_file_type(host_file);
  384. if (type == OS_TYPE_FILE) {
  385. fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
  386. if (fd >= 0)
  387. data->host_fd = fd;
  388. else
  389. printk(KERN_ERR "hppfs_open : failed to open '%s', "
  390. "errno = %d\n", host_file, -fd);
  391. data->contents = NULL;
  392. } else if (type == OS_TYPE_DIR) {
  393. fd = open_host_sock(host_file, &filter);
  394. if (fd > 0) {
  395. data->contents = hppfs_get_data(fd, filter,
  396. data->proc_file,
  397. file, &data->len);
  398. if (!IS_ERR(data->contents))
  399. data->host_fd = fd;
  400. } else
  401. printk(KERN_ERR "hppfs_open : failed to open a socket "
  402. "in '%s', errno = %d\n", host_file, -fd);
  403. }
  404. kfree(host_file);
  405. file->private_data = data;
  406. return 0;
  407. out_free1:
  408. kfree(host_file);
  409. out_free2:
  410. free_contents(data->contents);
  411. kfree(data);
  412. out:
  413. return err;
  414. }
  415. static int hppfs_dir_open(struct inode *inode, struct file *file)
  416. {
  417. const struct cred *cred = current_cred();
  418. struct hppfs_private *data;
  419. struct vfsmount *proc_mnt;
  420. struct dentry *proc_dentry;
  421. int err;
  422. err = -ENOMEM;
  423. data = hppfs_data();
  424. if (data == NULL)
  425. goto out;
  426. proc_dentry = HPPFS_I(inode)->proc_dentry;
  427. proc_mnt = inode->i_sb->s_fs_info;
  428. data->proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt),
  429. file_mode(file->f_mode), cred);
  430. err = PTR_ERR(data->proc_file);
  431. if (IS_ERR(data->proc_file))
  432. goto out_free;
  433. file->private_data = data;
  434. return 0;
  435. out_free:
  436. kfree(data);
  437. out:
  438. return err;
  439. }
  440. static loff_t hppfs_llseek(struct file *file, loff_t off, int where)
  441. {
  442. struct hppfs_private *data = file->private_data;
  443. struct file *proc_file = data->proc_file;
  444. loff_t (*llseek)(struct file *, loff_t, int);
  445. loff_t ret;
  446. llseek = proc_file->f_path.dentry->d_inode->i_fop->llseek;
  447. if (llseek != NULL) {
  448. ret = (*llseek)(proc_file, off, where);
  449. if (ret < 0)
  450. return ret;
  451. }
  452. return default_llseek(file, off, where);
  453. }
  454. static const struct file_operations hppfs_file_fops = {
  455. .owner = NULL,
  456. .llseek = hppfs_llseek,
  457. .read = hppfs_read,
  458. .write = hppfs_write,
  459. .open = hppfs_open,
  460. };
  461. struct hppfs_dirent {
  462. void *vfs_dirent;
  463. filldir_t filldir;
  464. struct dentry *dentry;
  465. };
  466. static int hppfs_filldir(void *d, const char *name, int size,
  467. loff_t offset, u64 inode, unsigned int type)
  468. {
  469. struct hppfs_dirent *dirent = d;
  470. if (file_removed(dirent->dentry, name))
  471. return 0;
  472. return (*dirent->filldir)(dirent->vfs_dirent, name, size, offset,
  473. inode, type);
  474. }
  475. static int hppfs_readdir(struct file *file, void *ent, filldir_t filldir)
  476. {
  477. struct hppfs_private *data = file->private_data;
  478. struct file *proc_file = data->proc_file;
  479. int (*readdir)(struct file *, void *, filldir_t);
  480. struct hppfs_dirent dirent = ((struct hppfs_dirent)
  481. { .vfs_dirent = ent,
  482. .filldir = filldir,
  483. .dentry = file->f_path.dentry
  484. });
  485. int err;
  486. readdir = proc_file->f_path.dentry->d_inode->i_fop->readdir;
  487. proc_file->f_pos = file->f_pos;
  488. err = (*readdir)(proc_file, &dirent, hppfs_filldir);
  489. file->f_pos = proc_file->f_pos;
  490. return err;
  491. }
  492. static int hppfs_fsync(struct file *file, struct dentry *dentry, int datasync)
  493. {
  494. return 0;
  495. }
  496. static const struct file_operations hppfs_dir_fops = {
  497. .owner = NULL,
  498. .readdir = hppfs_readdir,
  499. .open = hppfs_dir_open,
  500. .fsync = hppfs_fsync,
  501. };
  502. static int hppfs_statfs(struct dentry *dentry, struct kstatfs *sf)
  503. {
  504. sf->f_blocks = 0;
  505. sf->f_bfree = 0;
  506. sf->f_bavail = 0;
  507. sf->f_files = 0;
  508. sf->f_ffree = 0;
  509. sf->f_type = HPPFS_SUPER_MAGIC;
  510. return 0;
  511. }
  512. static struct inode *hppfs_alloc_inode(struct super_block *sb)
  513. {
  514. struct hppfs_inode_info *hi;
  515. hi = kmalloc(sizeof(*hi), GFP_KERNEL);
  516. if (!hi)
  517. return NULL;
  518. hi->proc_dentry = NULL;
  519. inode_init_once(&hi->vfs_inode);
  520. return &hi->vfs_inode;
  521. }
  522. void hppfs_delete_inode(struct inode *ino)
  523. {
  524. dput(HPPFS_I(ino)->proc_dentry);
  525. mntput(ino->i_sb->s_fs_info);
  526. clear_inode(ino);
  527. }
  528. static void hppfs_destroy_inode(struct inode *inode)
  529. {
  530. kfree(HPPFS_I(inode));
  531. }
  532. static const struct super_operations hppfs_sbops = {
  533. .alloc_inode = hppfs_alloc_inode,
  534. .destroy_inode = hppfs_destroy_inode,
  535. .delete_inode = hppfs_delete_inode,
  536. .statfs = hppfs_statfs,
  537. };
  538. static int hppfs_readlink(struct dentry *dentry, char __user *buffer,
  539. int buflen)
  540. {
  541. struct dentry *proc_dentry;
  542. proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
  543. return proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer,
  544. buflen);
  545. }
  546. static void *hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
  547. {
  548. struct dentry *proc_dentry;
  549. proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
  550. return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd);
  551. }
  552. static const struct inode_operations hppfs_dir_iops = {
  553. .lookup = hppfs_lookup,
  554. };
  555. static const struct inode_operations hppfs_link_iops = {
  556. .readlink = hppfs_readlink,
  557. .follow_link = hppfs_follow_link,
  558. };
  559. static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
  560. {
  561. struct inode *proc_ino = dentry->d_inode;
  562. struct inode *inode = new_inode(sb);
  563. if (!inode)
  564. return ERR_PTR(-ENOMEM);
  565. if (S_ISDIR(dentry->d_inode->i_mode)) {
  566. inode->i_op = &hppfs_dir_iops;
  567. inode->i_fop = &hppfs_dir_fops;
  568. } else if (S_ISLNK(dentry->d_inode->i_mode)) {
  569. inode->i_op = &hppfs_link_iops;
  570. inode->i_fop = &hppfs_file_fops;
  571. } else {
  572. inode->i_op = &hppfs_file_iops;
  573. inode->i_fop = &hppfs_file_fops;
  574. }
  575. HPPFS_I(inode)->proc_dentry = dget(dentry);
  576. inode->i_uid = proc_ino->i_uid;
  577. inode->i_gid = proc_ino->i_gid;
  578. inode->i_atime = proc_ino->i_atime;
  579. inode->i_mtime = proc_ino->i_mtime;
  580. inode->i_ctime = proc_ino->i_ctime;
  581. inode->i_ino = proc_ino->i_ino;
  582. inode->i_mode = proc_ino->i_mode;
  583. inode->i_nlink = proc_ino->i_nlink;
  584. inode->i_size = proc_ino->i_size;
  585. inode->i_blocks = proc_ino->i_blocks;
  586. return inode;
  587. }
  588. static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
  589. {
  590. struct inode *root_inode;
  591. struct vfsmount *proc_mnt;
  592. int err = -ENOENT;
  593. proc_mnt = do_kern_mount("proc", 0, "proc", NULL);
  594. if (IS_ERR(proc_mnt))
  595. goto out;
  596. sb->s_blocksize = 1024;
  597. sb->s_blocksize_bits = 10;
  598. sb->s_magic = HPPFS_SUPER_MAGIC;
  599. sb->s_op = &hppfs_sbops;
  600. sb->s_fs_info = proc_mnt;
  601. err = -ENOMEM;
  602. root_inode = get_inode(sb, proc_mnt->mnt_sb->s_root);
  603. if (!root_inode)
  604. goto out_mntput;
  605. sb->s_root = d_alloc_root(root_inode);
  606. if (!sb->s_root)
  607. goto out_iput;
  608. return 0;
  609. out_iput:
  610. iput(root_inode);
  611. out_mntput:
  612. mntput(proc_mnt);
  613. out:
  614. return(err);
  615. }
  616. static int hppfs_read_super(struct file_system_type *type,
  617. int flags, const char *dev_name,
  618. void *data, struct vfsmount *mnt)
  619. {
  620. return get_sb_nodev(type, flags, data, hppfs_fill_super, mnt);
  621. }
  622. static struct file_system_type hppfs_type = {
  623. .owner = THIS_MODULE,
  624. .name = "hppfs",
  625. .get_sb = hppfs_read_super,
  626. .kill_sb = kill_anon_super,
  627. .fs_flags = 0,
  628. };
  629. static int __init init_hppfs(void)
  630. {
  631. return register_filesystem(&hppfs_type);
  632. }
  633. static void __exit exit_hppfs(void)
  634. {
  635. unregister_filesystem(&hppfs_type);
  636. }
  637. module_init(init_hppfs)
  638. module_exit(exit_hppfs)
  639. MODULE_LICENSE("GPL");