static int ratpfs_probe(struct device_d *dev) { int len_tx = 1; /* type */ struct ratp_bb_pkt *pkt_tx = xzalloc(sizeof(*pkt_tx) + len_tx); struct ratp_bb_pkt *pkt_rx = NULL; int ret; struct fs_device_d *fsdev = dev_to_fs_device(dev); pr_debug("%s\n", __func__); ret = barebox_ratp_fs_mount(fsdev->path); if (ret) return ret; pkt_tx->len = len_tx; pkt_tx->data[0] = RATPFS_TYPE_MOUNT_CALL; ret = barebox_ratp_fs_call(pkt_tx, &pkt_rx); if (ret) goto out; if (pkt_rx->len < 1 || pkt_rx->data[0] != RATPFS_TYPE_MOUNT_RETURN) { pr_err("invalid mount response\n"); ret = -EINVAL; goto out; } out: free(pkt_rx); if (ret) barebox_ratp_fs_mount(NULL); return ret; }
static int fat_probe(struct device_d *dev) { struct fs_device_d *fsdev = dev_to_fs_device(dev); struct fat_priv *priv = xzalloc(sizeof(struct fat_priv)); char *backingstore = fsdev->backingstore; int ret; dev->priv = priv; if (!strncmp(backingstore , "/dev/", 5)) backingstore += 5; priv->cdev = cdev_open(backingstore, O_RDWR); if (!priv->cdev) { ret = -ENOENT; goto err_open; } priv->fat.userdata = priv; ret = f_mount(&priv->fat); if (ret) goto err_mount; return 0; err_mount: cdev_close(priv->cdev); err_open: free(priv); return ret; }
static int ext_probe(struct device_d *dev) { struct fs_device_d *fsdev = dev_to_fs_device(dev); int ret; struct ext_filesystem *fs; fs = xzalloc(sizeof(*fs)); dev->priv = fs; fs->dev = dev; ret = fsdev_open_cdev(fsdev); if (ret) goto err_open; fs->cdev = fsdev->cdev; ret = ext4fs_mount(fs); if (ret) goto err_mount; return 0; err_mount: err_open: free(fs); return ret; }
static int tftp_probe(struct device_d *dev) { struct fs_device_d *fsdev = dev_to_fs_device(dev); struct tftp_priv *priv = xzalloc(sizeof(struct tftp_priv)); dev->priv = priv; priv->server = resolv(fsdev->backingstore); return 0; }
static int ubifs_probe(struct device_d *dev) { struct fs_device_d *fsdev = dev_to_fs_device(dev); struct ubifs_priv *priv = xzalloc(sizeof(struct ubifs_priv)); int ret; dev->priv = priv; ret = fsdev_open_cdev(fsdev); if (ret) goto err_free; priv->cdev = fsdev->cdev; priv->ubi = ubi_open_volume_cdev(priv->cdev, UBI_READONLY); if (IS_ERR(priv->ubi)) { dev_err(dev, "failed to open ubi volume: %s\n", strerrorp(priv->ubi)); ret = PTR_ERR(priv->ubi); goto err_free; } ret = ubifs_get_super(dev, priv->ubi, 0); if (ret) goto err; priv->sb = &fsdev->sb; ubifs_set_rootarg(priv, fsdev); return 0; err: ubi_close_volume(priv->ubi); err_free: free(priv); return ret; }
static int nfs_probe(struct device_d *dev) { struct fs_device_d *fsdev = dev_to_fs_device(dev); struct nfs_priv *npriv = xzalloc(sizeof(struct nfs_priv)); char *tmp = xstrdup(fsdev->backingstore); char *path; int ret; dev->priv = npriv; debug("nfs: mount: %s\n", fsdev->backingstore); path = strchr(tmp, ':'); if (!path) { ret = -EINVAL; goto err; } *path = 0; npriv->path = xstrdup(path + 1); npriv->server = resolv(tmp); debug("nfs: server: %s path: %s\n", tmp, npriv->path); npriv->con = net_udp_new(npriv->server, 0, nfs_handler, npriv); if (IS_ERR(npriv->con)) { ret = PTR_ERR(npriv->con); goto err1; } /* Need a priviliged source port */ net_udp_bind(npriv->con, 1000); ret = rpc_lookup_req(npriv, PROG_MOUNT, 1); if (ret) { printf("lookup mount port failed with %d\n", ret); goto err2; } ret = rpc_lookup_req(npriv, PROG_NFS, 2); if (ret) { printf("lookup nfs port failed with %d\n", ret); goto err2; } ret = nfs_mount_req(npriv); if (ret) { printf("mounting failed with %d\n", ret); goto err2; } free(tmp); return 0; err2: net_unregister(npriv->con); err1: free(npriv->path); err: free(tmp); free(npriv); return ret; }