Konubinix' opinionated web of thoughts

Ipfs Fuse Mount > 0.12.2 Does Not Work for Several Files

Fleeting

ipfs mount > 0.12.2 does not work for several files

https://github.com/ipfs/kubo/issues/9044

cd kubo
go build ./cmd/ipfs
export IPFS_PATH=${TMPDIR}/ipfs
rm -rf ${IPFS_PATH}
./ipfs init
peerid="$(grep "PeerID" "${IPFS_PATH}/config")"
privkey="$(grep "PrivKey" "${IPFS_PATH}/config")"
cat<<EOF> ${IPFS_PATH}/config
{
  "Identity": {
${peerid}
${privkey}
  },
  "Datastore": {
    "StorageMax": "10GB",
    "StorageGCWatermark": 90,
    "GCPeriod": "1h",
    "Spec": {
      "mounts": [
        {
          "child": {
            "path": "blocks",
            "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
            "sync": true,
            "type": "flatfs"
          },
          "mountpoint": "/blocks",
          "prefix": "flatfs.datastore",
          "type": "measure"
        },
        {
          "child": {
            "compression": "none",
            "path": "datastore",
            "type": "levelds"
          },
          "mountpoint": "/",
          "prefix": "leveldb.datastore",
          "type": "measure"
        }
      ],
      "type": "mount"
    },
    "HashOnRead": false,
    "BloomFilterSize": 0
  },
  "Addresses": {
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4002",
      "/ip6/::/tcp/4002",
      "/ip4/0.0.0.0/udp/4002/quic",
      "/ip6/::/udp/4002/quic"
    ],
    "Announce": [],
    "AppendAnnounce": [],
    "NoAnnounce": [],
    "API": "/ip4/127.0.0.1/tcp/5003",
    "Gateway": "/ip4/127.0.0.1/tcp/8081"
  },
  "Mounts": {
    "IPFS": "/tmp/ipfs",
    "IPNS": "/tmp/ipns",
    "FuseAllowOther": false
  },
  "Discovery": {
    "MDNS": {
      "Enabled": true
    }
  },
  "Routing": {
    "Type": "dht",
    "Routers": null,
    "Methods": null
  },
  "Ipns": {
    "RepublishPeriod": "",
    "RecordLifetime": "",
    "ResolveCacheSize": 128
  },
  "Bootstrap": [ ],
  "Gateway": {
    "HTTPHeaders": {
      "Access-Control-Allow-Headers": [
        "X-Requested-With",
        "Range",
        "User-Agent"
      ],
      "Access-Control-Allow-Methods": [
        "GET"
      ],
      "Access-Control-Allow-Origin": [
        "*"
      ]
    },
    "RootRedirect": "",
    "Writable": false,
    "PathPrefixes": [],
    "APICommands": [],
    "NoFetch": false,
    "NoDNSLink": false,
    "PublicGateways": null
  },
  "API": {
    "HTTPHeaders": {}
  },
  "Swarm": {
    "AddrFilters": null,
    "DisableBandwidthMetrics": false,
    "DisableNatPortMap": false,
    "RelayClient": {},
    "RelayService": {},
    "Transports": {
      "Network": {},
      "Security": {},
      "Multiplexers": {}
    },
    "ConnMgr": {},
    "ResourceMgr": {}
  },
  "AutoNAT": {},
  "Pubsub": {
    "Router": "",
    "DisableSigning": false
  },
  "Peering": {
    "Peers": null
  },
  "DNS": {
    "Resolvers": {}
  },
  "Migration": {
    "DownloadSources": [],
    "Keep": ""
  },
  "Provider": {
    "Strategy": ""
  },
  "Reprovider": {
    "Interval": "12h",
    "Strategy": "all"
  },
  "Experimental": {
    "FilestoreEnabled": false,
    "UrlstoreEnabled": false,
    "GraphsyncEnabled": false,
    "Libp2pStreamMounting": false,
    "P2pHttpProxy": false,
    "StrategicProviding": false,
    "AcceleratedDHTClient": false
  },
  "Plugins": {
    "Plugins": null
  },
  "Pinning": {
    "RemoteServices": {}
  },
  "Internal": {}
}
EOF

mkdir -p /tmp/ip{f,n}s
echo a | ./ipfs add -
./ipfs daemon
./ipfs cat Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9
a
./ipfs mount
IPFS mounted at: /tmp/ipfs
IPNS mounted at: /tmp/ipns
cat /tmp/ipfs/Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9
cat: /tmp/ipfs/Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9: No such file or directory

And in the log of the daemon, we can see

2023-06-14T15:45:26.703+0200    ERROR   fuse/ipfs       readonly/readonly_unix.go:107   could not convert protobuf or raw node

But, the gateway works fine though.

http get http://localhost:8081/ipfs/Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9
a

It might be useful to check how its code works so that we can reproduce this behavior in ipfs mount.

dlv debug --headless --listen 0.0.0.0:2345 ./cmd/ipfs -- daemon

By debugging the code, I can see that the part dealing with those requests is in

gopath/pkg/mod/github.com/ipfs/boxo@v0.8.1-0.20230411232920-5d6c73c8e35e/gateway/blocks_gateway.go:142, in the method Get of the struct BlocksGateway of boxo.

func (api *BlocksGateway) Get(ctx context.Context, path ImmutablePath, ranges ...ByteRange) (ContentPathMetadata, *GetResponse, error) {

When playing with the mount, the problematic code is in kubo/fuse/readonly/readonly_unix.go in the method lookup.