littlefs-python 0.18.0__tar.gz → 0.19.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/.github/workflows/deploy.yml +35 -9
  2. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/.github/workflows/run-tests.yml +10 -2
  3. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/PKG-INFO +1 -1
  4. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/README.md +1 -1
  5. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/lfs.c +25 -16
  6. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/lfs.h +6 -5
  7. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_alloc.toml +183 -0
  8. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/lfs.c +494 -289
  9. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/PKG-INFO +1 -1
  10. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/SOURCES.txt +2 -0
  11. littlefs_python-0.19.0/src/littlefs_python.egg-info/scm_file_list.json +131 -0
  12. littlefs_python-0.19.0/src/littlefs_python.egg-info/scm_version.json +8 -0
  13. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/.gitattributes +0 -0
  14. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/.github/dependabot.yml +0 -0
  15. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/.gitignore +0 -0
  16. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/.gitmodules +0 -0
  17. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/.pre-commit-config.yaml +0 -0
  18. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/.readthedocs.yml +0 -0
  19. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/LICENSE +0 -0
  20. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/MANIFEST.in +0 -0
  21. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/README.rst +0 -0
  22. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/ci/build-wheels.sh +0 -0
  23. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/ci/download_release_files.py +0 -0
  24. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/Makefile +0 -0
  25. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/api/index.rst +0 -0
  26. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/cli.rst +0 -0
  27. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/conf.py +0 -0
  28. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/doc8.ini +0 -0
  29. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/examples/index.rst +0 -0
  30. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/index.rst +0 -0
  31. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/make.bat +0 -0
  32. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/requirements.txt +0 -0
  33. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/docs/usage.rst +0 -0
  34. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/examples/mkfsimg.py +0 -0
  35. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/examples/walk.py +0 -0
  36. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/.git +0 -0
  37. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/.gitattributes +0 -0
  38. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/.github/workflows/post-release.yml +0 -0
  39. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/.github/workflows/release.yml +0 -0
  40. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/.github/workflows/status.yml +0 -0
  41. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/.github/workflows/test.yml +0 -0
  42. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/.gitignore +0 -0
  43. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/DESIGN.md +0 -0
  44. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/LICENSE.md +0 -0
  45. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/Makefile +0 -0
  46. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/SPEC.md +0 -0
  47. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/bd/lfs_emubd.c +0 -0
  48. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/bd/lfs_emubd.h +0 -0
  49. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/bd/lfs_filebd.c +0 -0
  50. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/bd/lfs_filebd.h +0 -0
  51. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/bd/lfs_rambd.c +0 -0
  52. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/bd/lfs_rambd.h +0 -0
  53. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/benches/bench_dir.toml +0 -0
  54. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/benches/bench_file.toml +0 -0
  55. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/benches/bench_superblock.toml +0 -0
  56. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/lfs_util.c +0 -0
  57. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/lfs_util.h +0 -0
  58. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/runners/bench_runner.c +0 -0
  59. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/runners/bench_runner.h +0 -0
  60. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/runners/test_runner.c +0 -0
  61. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/runners/test_runner.h +0 -0
  62. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/bench.py +0 -0
  63. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/changeprefix.py +0 -0
  64. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/code.py +0 -0
  65. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/cov.py +0 -0
  66. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/data.py +0 -0
  67. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/perf.py +0 -0
  68. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/perfbd.py +0 -0
  69. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/plot.py +0 -0
  70. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/plotmpl.py +0 -0
  71. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/prettyasserts.py +0 -0
  72. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/readblock.py +0 -0
  73. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/readmdir.py +0 -0
  74. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/readtree.py +0 -0
  75. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/stack.py +0 -0
  76. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/structs.py +0 -0
  77. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/summary.py +0 -0
  78. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/tailpipe.py +0 -0
  79. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/teepipe.py +0 -0
  80. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/test.py +0 -0
  81. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/tracebd.py +0 -0
  82. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/scripts/watch.py +0 -0
  83. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_attrs.toml +0 -0
  84. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_badblocks.toml +0 -0
  85. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_bd.toml +0 -0
  86. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_compat.toml +0 -0
  87. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_dirs.toml +0 -0
  88. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_entries.toml +0 -0
  89. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_evil.toml +0 -0
  90. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_exhaustion.toml +0 -0
  91. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_files.toml +0 -0
  92. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_interspersed.toml +0 -0
  93. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_move.toml +0 -0
  94. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_orphans.toml +0 -0
  95. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_paths.toml +0 -0
  96. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_powerloss.toml +0 -0
  97. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_relocations.toml +0 -0
  98. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_seek.toml +0 -0
  99. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_shrink.toml +0 -0
  100. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_superblocks.toml +0 -0
  101. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/littlefs/tests/test_truncate.toml +0 -0
  102. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/mypy.ini +0 -0
  103. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/pyproject.toml +0 -0
  104. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/requirements.txt +0 -0
  105. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/setup.cfg +0 -0
  106. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/setup.py +0 -0
  107. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/__init__.py +0 -0
  108. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/__main__.py +0 -0
  109. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/context.py +0 -0
  110. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/errors.py +0 -0
  111. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/lfs.pxd +0 -0
  112. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/lfs.pyi +0 -0
  113. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/lfs.pyx +0 -0
  114. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/py.typed +0 -0
  115. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs/repl.py +0 -0
  116. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/dependency_links.txt +0 -0
  117. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/entry_points.txt +0 -0
  118. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/not-zip-safe +0 -0
  119. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/requires.txt +0 -0
  120. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/src/littlefs_python.egg-info/top_level.txt +0 -0
  121. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/cli/test_create_and_extract.py +0 -0
  122. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/cli/test_create_and_repl.py +0 -0
  123. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/cli/test_walk_all.py +0 -0
  124. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/lfs/conftest.py +0 -0
  125. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/lfs/test_dir_functions.py +0 -0
  126. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/lfs/test_file_functions.py +0 -0
  127. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/lfs/test_fs_functions.py +0 -0
  128. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_attr.py +0 -0
  129. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_block_count.py +0 -0
  130. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_context.py +0 -0
  131. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_directories.py +0 -0
  132. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_files.py +0 -0
  133. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_grow.py +0 -0
  134. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_multiversion.py +0 -0
  135. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_name_max.py +0 -0
  136. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_remove_rename.py +0 -0
  137. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_unicode_filenames.py +0 -0
  138. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_version.py +0 -0
  139. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_walk.py +0 -0
  140. {littlefs_python-0.18.0 → littlefs_python-0.19.0}/test/test_windisk_context.py +0 -0
@@ -23,21 +23,21 @@ jobs:
23
23
  CIBW_ARCHS_LINUX: "x86_64 i686 aarch64"
24
24
 
25
25
  steps:
26
- - uses: actions/checkout@v6
26
+ - uses: actions/checkout@v7
27
27
  with:
28
28
  submodules: "recursive"
29
29
  fetch-depth: 0
30
30
 
31
31
  - name: Setup QEMU # Needed to build aarch64 wheels
32
32
  if: runner.os == 'Linux'
33
- uses: docker/setup-qemu-action@v3
33
+ uses: docker/setup-qemu-action@v4
34
34
  with:
35
35
  platforms: all
36
36
 
37
37
  - name: Build wheels
38
38
  uses: pypa/cibuildwheel@v3.4.1
39
39
 
40
- - uses: actions/upload-artifact@v6
40
+ - uses: actions/upload-artifact@v7
41
41
  with:
42
42
  name: wheels-${{ matrix.os }}
43
43
  path: ./wheelhouse/*.whl
@@ -51,7 +51,7 @@ jobs:
51
51
  cibw_archs: ["arm64"]
52
52
 
53
53
  steps:
54
- - uses: actions/checkout@v6
54
+ - uses: actions/checkout@v7
55
55
  with:
56
56
  submodules: "recursive"
57
57
  fetch-depth: 0
@@ -84,16 +84,42 @@ jobs:
84
84
  delocate-listdeps --all {dest_dir}/$WHEEL_SIMPLE_FILENAME
85
85
 
86
86
  echo "DONE."
87
- - uses: actions/upload-artifact@v6
87
+ - uses: actions/upload-artifact@v7
88
88
  with:
89
89
  name: wheels-macos-arm64
90
90
  path: ./wheelhouse/*.whl
91
91
 
92
+ build_wheels_windows_arm64:
93
+ name: Build ARM64 wheels on ${{ matrix.os }}
94
+ runs-on: ${{ matrix.os }}
95
+ strategy:
96
+ matrix:
97
+ os: [windows-11-arm]
98
+
99
+ env:
100
+ # Native ARM64 CPython builds on Windows are available for 3.11+.
101
+ CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-*"
102
+ CIBW_ARCHS_WINDOWS: "ARM64"
103
+
104
+ steps:
105
+ - uses: actions/checkout@v6
106
+ with:
107
+ submodules: "recursive"
108
+ fetch-depth: 0
109
+
110
+ - name: Build wheels
111
+ uses: pypa/cibuildwheel@v3.4.1
112
+
113
+ - uses: actions/upload-artifact@v6
114
+ with:
115
+ name: wheels-windows-arm64
116
+ path: ./wheelhouse/*.whl
117
+
92
118
  build_sdist:
93
119
  name: Build source distribution
94
120
  runs-on: ubuntu-22.04
95
121
  steps:
96
- - uses: actions/checkout@v6
122
+ - uses: actions/checkout@v7
97
123
  with:
98
124
  submodules: "recursive"
99
125
  fetch-depth: 0
@@ -103,17 +129,17 @@ jobs:
103
129
  pip install build
104
130
  python -m build . --sdist
105
131
 
106
- - uses: actions/upload-artifact@v6
132
+ - uses: actions/upload-artifact@v7
107
133
  with:
108
134
  name: wheels-sdist
109
135
  path: dist/*.tar.gz
110
136
 
111
137
  upload_pypi:
112
- needs: [build_wheels, build_wheels_macos_arm64, build_sdist]
138
+ needs: [build_wheels, build_wheels_macos_arm64, build_wheels_windows_arm64, build_sdist]
113
139
  runs-on: ubuntu-22.04
114
140
  if: ${{ inputs.upload_to_pypi }}
115
141
  steps:
116
- - uses: actions/download-artifact@v7
142
+ - uses: actions/download-artifact@v8
117
143
  with:
118
144
  path: dist
119
145
  pattern: wheels-*
@@ -14,11 +14,19 @@ jobs:
14
14
  runs-on: ${{ matrix.os }}
15
15
  strategy:
16
16
  matrix:
17
- os: [ubuntu-22.04, macos-15, windows-latest]
17
+ os: [ubuntu-22.04, macos-15, windows-latest, windows-11-arm]
18
18
  python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13", "3.14"]
19
+ exclude:
20
+ # Native ARM64 CPython builds on Windows are available for 3.11+.
21
+ - os: windows-11-arm
22
+ python-version: 3.8
23
+ - os: windows-11-arm
24
+ python-version: 3.9
25
+ - os: windows-11-arm
26
+ python-version: "3.10"
19
27
 
20
28
  steps:
21
- - uses: actions/checkout@v6
29
+ - uses: actions/checkout@v7
22
30
  with:
23
31
  submodules: "recursive"
24
32
  - name: Set up Python ${{ matrix.python-version }}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: littlefs-python
3
- Version: 0.18.0
3
+ Version: 0.19.0
4
4
  Summary: A python wrapper for littlefs
5
5
  Home-page: https://github.com/jrast/littlefs-python
6
6
  Author: Jürg Rast
@@ -192,7 +192,7 @@ More details on how littlefs works can be found in [DESIGN.md](DESIGN.md) and
192
192
  ## Testing
193
193
 
194
194
  The littlefs comes with a test suite designed to run on a PC using the
195
- [emulated block device](bd/lfs_testbd.h) found in the `bd` directory.
195
+ [emulated block device](bd/lfs_emubd.h) found in the `bd` directory.
196
196
  The tests assume a Linux environment and can be started with make:
197
197
 
198
198
  ``` bash
@@ -258,7 +258,7 @@ static int lfs_bd_prog(lfs_t *lfs,
258
258
  continue;
259
259
  }
260
260
 
261
- // pcache must have been flushed, either by programming and
261
+ // pcache must have been flushed, either by programming an
262
262
  // entire block or manually flushing the pcache
263
263
  LFS_ASSERT(pcache->block == LFS_BLOCK_NULL);
264
264
 
@@ -286,7 +286,7 @@ static int lfs_bd_erase(lfs_t *lfs, lfs_block_t block) {
286
286
 
287
287
  // some operations on paths
288
288
  static inline lfs_size_t lfs_path_namelen(const char *path) {
289
- return strcspn(path, "/");
289
+ return (lfs_size_t)strcspn(path, "/");
290
290
  }
291
291
 
292
292
  static inline bool lfs_path_islast(const char *path) {
@@ -1291,6 +1291,7 @@ static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs,
1291
1291
 
1292
1292
  // found a match for our fetcher?
1293
1293
  if ((fmask & tag) == (fmask & ftag)) {
1294
+ LFS_ASSERT(cb != NULL);
1294
1295
  int res = cb(data, tag, &(struct lfs_diskoff){
1295
1296
  dir->pair[0], off+sizeof(tag)});
1296
1297
  if (res < 0) {
@@ -1501,7 +1502,7 @@ nextname:
1501
1502
  if (lfs_tag_type3(tag) == LFS_TYPE_DIR) {
1502
1503
  name += strspn(name, "/");
1503
1504
  }
1504
- lfs_size_t namelen = strcspn(name, "/");
1505
+ lfs_size_t namelen = (lfs_size_t)strcspn(name, "/");
1505
1506
 
1506
1507
  // skip '.'
1507
1508
  if (namelen == 1 && memcmp(name, ".", 1) == 0) {
@@ -1520,7 +1521,7 @@ nextname:
1520
1521
  int depth = 1;
1521
1522
  while (true) {
1522
1523
  suffix += strspn(suffix, "/");
1523
- sufflen = strcspn(suffix, "/");
1524
+ sufflen = (lfs_size_t)strcspn(suffix, "/");
1524
1525
  if (sufflen == 0) {
1525
1526
  break;
1526
1527
  }
@@ -1761,7 +1762,7 @@ static int lfs_dir_commitcrc(lfs_t *lfs, struct lfs_commit *commit) {
1761
1762
 
1762
1763
  commit->off = noff;
1763
1764
  // perturb valid bit?
1764
- commit->ptag = ntag ^ ((0x80UL & ~eperturb) << 24);
1765
+ commit->ptag = ntag ^ ((lfs_tag_t)(0x80 & ~eperturb) << 24);
1765
1766
  // reset crc for next commit
1766
1767
  commit->crc = 0xffffffff;
1767
1768
 
@@ -3244,10 +3245,12 @@ static int lfs_file_open_(lfs_t *lfs, lfs_file_t *file,
3244
3245
  #endif
3245
3246
 
3246
3247
  static int lfs_file_close_(lfs_t *lfs, lfs_file_t *file) {
3247
- #ifndef LFS_READONLY
3248
- int err = lfs_file_sync_(lfs, file);
3249
- #else
3250
3248
  int err = 0;
3249
+ #ifndef LFS_READONLY
3250
+ // it's not safe to do anything if our file errored
3251
+ if (!(file->flags & LFS_F_ERRED)) {
3252
+ err = lfs_file_sync_(lfs, file);
3253
+ }
3251
3254
  #endif
3252
3255
 
3253
3256
  // remove from list of mdirs
@@ -3429,18 +3432,12 @@ relocate:
3429
3432
 
3430
3433
  #ifndef LFS_READONLY
3431
3434
  static int lfs_file_sync_(lfs_t *lfs, lfs_file_t *file) {
3432
- if (file->flags & LFS_F_ERRED) {
3433
- // it's not safe to do anything if our file errored
3434
- return 0;
3435
- }
3436
-
3437
3435
  int err = lfs_file_flush(lfs, file);
3438
3436
  if (err) {
3439
3437
  file->flags |= LFS_F_ERRED;
3440
3438
  return err;
3441
3439
  }
3442
3440
 
3443
-
3444
3441
  if ((file->flags & LFS_F_DIRTY) &&
3445
3442
  !lfs_pair_isnull(file->m.pair)) {
3446
3443
  // before we commit metadata, we need sync the disk to make sure
@@ -3485,6 +3482,17 @@ static int lfs_file_sync_(lfs_t *lfs, lfs_file_t *file) {
3485
3482
  file->flags &= ~LFS_F_DIRTY;
3486
3483
  }
3487
3484
 
3485
+ // mark any other file handles as dirty + desync
3486
+ for (lfs_file_t *f = (lfs_file_t*)lfs->mlist; f; f = f->next) {
3487
+ if (file != f
3488
+ && f->type == LFS_TYPE_REG
3489
+ && lfs_pair_cmp(f->m.pair, file->m.pair) == 0
3490
+ && f->id == file->id) {
3491
+ f->flags |= LFS_F_DUSTY;
3492
+ }
3493
+ }
3494
+
3495
+ file->flags &= ~LFS_F_ERRED & ~LFS_F_DUSTY;
3488
3496
  return 0;
3489
3497
  }
3490
3498
  #endif
@@ -3692,7 +3700,7 @@ static lfs_ssize_t lfs_file_write_(lfs_t *lfs, lfs_file_t *file,
3692
3700
  return nsize;
3693
3701
  }
3694
3702
 
3695
- file->flags &= ~LFS_F_ERRED;
3703
+ file->flags &= ~LFS_F_ERRED & ~LFS_F_DUSTY;
3696
3704
  return nsize;
3697
3705
  }
3698
3706
  #endif
@@ -4771,7 +4779,8 @@ int lfs_fs_traverse_(lfs_t *lfs,
4771
4779
  continue;
4772
4780
  }
4773
4781
 
4774
- if ((f->flags & LFS_F_DIRTY) && !(f->flags & LFS_F_INLINE)) {
4782
+ if (((f->flags & LFS_F_DIRTY) || (f->flags & LFS_F_DUSTY))
4783
+ && !(f->flags & LFS_F_INLINE)) {
4775
4784
  int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
4776
4785
  f->ctz.head, f->ctz.size, cb, data);
4777
4786
  if (err) {
@@ -135,14 +135,15 @@ enum lfs_open_flags {
135
135
 
136
136
  // internally used flags
137
137
  #ifndef LFS_READONLY
138
- LFS_F_DIRTY = 0x010000, // File does not match storage
139
- LFS_F_WRITING = 0x020000, // File has been written since last flush
138
+ LFS_F_DIRTY = 0x00010000, // File does not match storage due to write
139
+ LFS_F_DUSTY = 0x00020000, // File does not match storage due to desync
140
+ LFS_F_WRITING = 0x00040000, // File has been written since last flush
140
141
  #endif
141
- LFS_F_READING = 0x040000, // File has been read since last flush
142
+ LFS_F_READING = 0x00080000, // File has been read since last flush
142
143
  #ifndef LFS_READONLY
143
- LFS_F_ERRED = 0x080000, // An error occurred during write
144
+ LFS_F_ERRED = 0x00100000, // An error occurred during write
144
145
  #endif
145
- LFS_F_INLINE = 0x100000, // Currently inlined in directory entry
146
+ LFS_F_INLINE = 0x01000000, // Currently inlined in directory entry
146
147
  };
147
148
 
148
149
  // File seek flags
@@ -250,6 +250,189 @@ code = '''
250
250
  }
251
251
  '''
252
252
 
253
+ # multiple handle allocation test
254
+ #
255
+ # this tests that multiple open handles to the same file don't clobber
256
+ # each other
257
+ [cases.test_alloc_multihandle]
258
+ defines.FILES = 2
259
+ defines.SIZE = '(((BLOCK_SIZE-8)*(BLOCK_COUNT-6)) / FILES)'
260
+ defines.GC = [false, true]
261
+ defines.COMPACT_THRESH = ['-1', '0', 'BLOCK_SIZE/2']
262
+ defines.INFER_BC = [false, true]
263
+ defines.SYNC = [false, true]
264
+ code = '''
265
+ const char *names[] = {"eggs", "spinach"};
266
+ lfs_file_t files[FILES];
267
+
268
+ lfs_t lfs;
269
+ lfs_format(&lfs, cfg) => 0;
270
+ struct lfs_config cfg_ = *cfg;
271
+ if (INFER_BC) {
272
+ cfg_.block_count = 0;
273
+ }
274
+ lfs_mount(&lfs, &cfg_) => 0;
275
+ lfs_mkdir(&lfs, "breakfast") => 0;
276
+
277
+ // write one file
278
+ char path[1024];
279
+ sprintf(path, "breakfast/quiche");
280
+ lfs_file_open(&lfs, &files[0], path,
281
+ LFS_O_RDWR | LFS_O_CREAT | LFS_O_EXCL) => 0;
282
+ if (GC) {
283
+ lfs_fs_gc(&lfs) => 0;
284
+ }
285
+ size_t size = strlen(names[0]);
286
+ for (lfs_size_t i = 0; i < SIZE; i += size) {
287
+ lfs_file_write(&lfs, &files[0], names[0], size) => size;
288
+ }
289
+ // sync?
290
+ if (SYNC) {
291
+ lfs_file_sync(&lfs, &files[0]) => 0;
292
+ }
293
+
294
+ // write the other file
295
+ sprintf(path, "breakfast/quiche");
296
+ lfs_file_open(&lfs, &files[1], path,
297
+ LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC) => 0;
298
+ if (GC) {
299
+ lfs_fs_gc(&lfs) => 0;
300
+ }
301
+ size = strlen(names[1]);
302
+ for (lfs_size_t i = 0; i < SIZE; i += size) {
303
+ lfs_file_write(&lfs, &files[1], names[1], size) => size;
304
+ }
305
+ // sync?
306
+ if (SYNC) {
307
+ lfs_file_sync(&lfs, &files[1]) => 0;
308
+ }
309
+
310
+ // try to read from both
311
+ for (int n = 0; n < FILES; n++) {
312
+ lfs_file_rewind(&lfs, &files[n]) => 0;
313
+ size_t size = strlen(names[n]);
314
+ for (lfs_size_t i = 0; i < SIZE; i += size) {
315
+ uint8_t buffer[1024];
316
+ lfs_file_read(&lfs, &files[n], buffer, size) => size;
317
+ assert(memcmp(buffer, names[n], size) == 0);
318
+ }
319
+ }
320
+ for (int n = 0; n < FILES; n++) {
321
+ lfs_file_close(&lfs, &files[n]) => 0;
322
+ }
323
+ lfs_unmount(&lfs) => 0;
324
+
325
+ // check after remounting
326
+ lfs_mount(&lfs, &cfg_) => 0;
327
+ {
328
+ // last one wins
329
+ int n = FILES-1;
330
+ char path[1024];
331
+ sprintf(path, "breakfast/quiche");
332
+ lfs_file_t file;
333
+ lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
334
+ size_t size = strlen(names[n]);
335
+ for (lfs_size_t i = 0; i < SIZE; i += size) {
336
+ uint8_t buffer[1024];
337
+ lfs_file_read(&lfs, &file, buffer, size) => size;
338
+ assert(memcmp(buffer, names[n], size) == 0);
339
+ }
340
+ lfs_file_close(&lfs, &file) => 0;
341
+ }
342
+ lfs_unmount(&lfs) => 0;
343
+ '''
344
+
345
+ # multiple handle allocation reuse test
346
+ [cases.test_alloc_multihandle_reuse]
347
+ defines.FILES = 2
348
+ defines.SIZE = '(((BLOCK_SIZE-8)*(BLOCK_COUNT-6)) / (FILES+1))'
349
+ defines.CYCLES = [1, 10]
350
+ defines.INFER_BC = [false, true]
351
+ defines.SYNC = [false, true]
352
+ code = '''
353
+ const char *names[] = {"eggs", "spinach"};
354
+ lfs_file_t files[FILES];
355
+
356
+ lfs_t lfs;
357
+ lfs_format(&lfs, cfg) => 0;
358
+ struct lfs_config cfg_ = *cfg;
359
+ if (INFER_BC) {
360
+ cfg_.block_count = 0;
361
+ }
362
+
363
+ lfs_mount(&lfs, &cfg_) => 0;
364
+ lfs_mkdir(&lfs, "breakfast") => 0;
365
+
366
+ // write one file
367
+ char path[1024];
368
+ sprintf(path, "breakfast/quiche");
369
+ lfs_file_open(&lfs, &files[0], path,
370
+ LFS_O_RDWR | LFS_O_CREAT | LFS_O_EXCL) => 0;
371
+ if (GC) {
372
+ lfs_fs_gc(&lfs) => 0;
373
+ }
374
+ size_t size = strlen(names[0]);
375
+ for (lfs_size_t i = 0; i < SIZE; i += size) {
376
+ lfs_file_write(&lfs, &files[0], names[0], size) => size;
377
+ }
378
+ // sync?
379
+ if (SYNC) {
380
+ lfs_file_sync(&lfs, &files[0]) => 0;
381
+ }
382
+
383
+ for (int c = 0; c < CYCLES; c++) {
384
+ // write the other file
385
+ sprintf(path, "breakfast/quiche");
386
+ lfs_file_open(&lfs, &files[1], path,
387
+ LFS_O_RDWR | LFS_O_CREAT | LFS_O_TRUNC) => 0;
388
+ if (GC) {
389
+ lfs_fs_gc(&lfs) => 0;
390
+ }
391
+ size = strlen(names[1]);
392
+ for (lfs_size_t i = 0; i < SIZE; i += size) {
393
+ lfs_file_write(&lfs, &files[1], names[1], size) => size;
394
+ }
395
+ // sync?
396
+ if (SYNC) {
397
+ lfs_file_sync(&lfs, &files[1]) => 0;
398
+ }
399
+
400
+ // try to read from both
401
+ for (int n = 0; n < FILES; n++) {
402
+ lfs_file_rewind(&lfs, &files[n]) => 0;
403
+ size_t size = strlen(names[n]);
404
+ for (lfs_size_t i = 0; i < SIZE; i += size) {
405
+ uint8_t buffer[1024];
406
+ lfs_file_read(&lfs, &files[n], buffer, size) => size;
407
+ assert(memcmp(buffer, names[n], size) == 0);
408
+ }
409
+ }
410
+
411
+ lfs_file_close(&lfs, &files[1]) => 0;
412
+ }
413
+ lfs_file_close(&lfs, &files[0]) => 0;
414
+ lfs_unmount(&lfs) => 0;
415
+
416
+ // check after remounting
417
+ lfs_mount(&lfs, &cfg_) => 0;
418
+ {
419
+ // last one wins
420
+ int n = (SYNC) ? FILES-1 : 0;
421
+ char path[1024];
422
+ sprintf(path, "breakfast/quiche");
423
+ lfs_file_t file;
424
+ lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
425
+ size_t size = strlen(names[n]);
426
+ for (int i = 0; i < SIZE; i += size) {
427
+ uint8_t buffer[1024];
428
+ lfs_file_read(&lfs, &file, buffer, size) => size;
429
+ assert(memcmp(buffer, names[n], size) == 0);
430
+ }
431
+ lfs_file_close(&lfs, &file) => 0;
432
+ }
433
+ lfs_unmount(&lfs) => 0;
434
+ '''
435
+
253
436
  # exhaustion test
254
437
  [cases.test_alloc_exhaustion]
255
438
  defines.INFER_BC = [false, true]