Rollup merge of #126135 - hermit-os:fuse, r=jhpratt · model-checking/verify-rust-std@afee9f5 (original) (raw)

1

1

`use super::fd::FileDesc;

`

2

2

`use super::hermit_abi::{

`

3

3

`self, dirent64, stat as stat_struct, DT_DIR, DT_LNK, DT_REG, DT_UNKNOWN, O_APPEND, O_CREAT,

`

4

``

`-

O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG,

`

``

4

`+

O_DIRECTORY, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG,

`

5

5

`};

`

6

6

`use crate::ffi::{CStr, OsStr, OsString};

`

7

7

`use crate::fmt;

`

`@@ -62,7 +62,7 @@ pub struct DirEntry {

`

62

62

`/// 64-bit inode number

`

63

63

`ino: u64,

`

64

64

`/// File type

`

65

``

`-

type_: u32,

`

``

65

`+

type_: u8,

`

66

66

`/// name of the entry

`

67

67

`name: OsString,

`

68

68

`}

`

`@@ -90,7 +90,7 @@ pub struct FilePermissions {

`

90

90

``

91

91

`#[derive(Copy, Clone, Eq, Debug)]

`

92

92

`pub struct FileType {

`

93

``

`-

mode: u32,

`

``

93

`+

mode: u8,

`

94

94

`}

`

95

95

``

96

96

`impl PartialEq for FileType {

`

`@@ -112,31 +112,23 @@ pub struct DirBuilder {

`

112

112

``

113

113

`impl FileAttr {

`

114

114

`pub fn modified(&self) -> io::Result {

`

115

``

`-

Ok(SystemTime::new(

`

116

``

`-

self.stat_val.st_mtime.try_into().unwrap(),

`

117

``

`-

self.stat_val.st_mtime_nsec.try_into().unwrap(),

`

118

``

`-

))

`

``

115

`+

Ok(SystemTime::new(self.stat_val.st_mtim.tv_sec, self.stat_val.st_mtim.tv_nsec))

`

119

116

`}

`

120

117

``

121

118

`pub fn accessed(&self) -> io::Result {

`

122

``

`-

Ok(SystemTime::new(

`

123

``

`-

self.stat_val.st_atime.try_into().unwrap(),

`

124

``

`-

self.stat_val.st_atime_nsec.try_into().unwrap(),

`

125

``

`-

))

`

``

119

`+

Ok(SystemTime::new(self.stat_val.st_atim.tv_sec, self.stat_val.st_atim.tv_nsec))

`

126

120

`}

`

127

121

``

128

122

`pub fn created(&self) -> io::Result {

`

129

``

`-

Ok(SystemTime::new(

`

130

``

`-

self.stat_val.st_ctime.try_into().unwrap(),

`

131

``

`-

self.stat_val.st_ctime_nsec.try_into().unwrap(),

`

132

``

`-

))

`

``

123

`+

Ok(SystemTime::new(self.stat_val.st_ctim.tv_sec, self.stat_val.st_ctim.tv_nsec))

`

133

124

`}

`

134

125

``

135

126

`pub fn size(&self) -> u64 {

`

136

127

`self.stat_val.st_size as u64

`

137

128

`}

`

``

129

+

138

130

`pub fn perm(&self) -> FilePermissions {

`

139

``

`-

FilePermissions { mode: (self.stat_val.st_mode) }

`

``

131

`+

FilePermissions { mode: self.stat_val.st_mode }

`

140

132

`}

`

141

133

``

142

134

`pub fn file_type(&self) -> FileType {

`

`@@ -220,7 +212,7 @@ impl Iterator for ReadDir {

`

220

212

`let entry = DirEntry {

`

221

213

`root: self.inner.root.clone(),

`

222

214

`ino: dir.d_ino,

`

223

``

`-

type_: dir.d_type as u32,

`

``

215

`+

type_: dir.d_type,

`

224

216

`name: OsString::from_vec(name_bytes.to_vec()),

`

225

217

`};

`

226

218

``

`@@ -251,7 +243,7 @@ impl DirEntry {

`

251

243

`}

`

252

244

``

253

245

`pub fn file_type(&self) -> io::Result {

`

254

``

`-

Ok(FileType { mode: self.type_ as u32 })

`

``

246

`+

Ok(FileType { mode: self.type_ })

`

255

247

`}

`

256

248

``

257

249

`#[allow(dead_code)]

`

`@@ -385,12 +377,12 @@ impl File {

`

385

377

`}

`

386

378

``

387

379

`pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result {

`

388

``

`-

crate::io::default_read_vectored(|buf| self.read(buf), bufs)

`

``

380

`+

self.0.read_vectored(bufs)

`

389

381

`}

`

390

382

``

391

383

`#[inline]

`

392

384

`pub fn is_read_vectored(&self) -> bool {

`

393

``

`-

false

`

``

385

`+

self.0.is_read_vectored()

`

394

386

`}

`

395

387

``

396

388

`pub fn read_buf(&self, cursor: BorrowedCursor<'_>) -> io::Result<()> {

`

`@@ -402,12 +394,12 @@ impl File {

`

402

394

`}

`

403

395

``

404

396

`pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result {

`

405

``

`-

crate::io::default_write_vectored(|buf| self.write(buf), bufs)

`

``

397

`+

self.0.write_vectored(bufs)

`

406

398

`}

`

407

399

``

408

400

`#[inline]

`

409

401

`pub fn is_write_vectored(&self) -> bool {

`

410

``

`-

false

`

``

402

`+

self.0.is_write_vectored()

`

411

403

`}

`

412

404

``

413

405

`#[inline]

`

`@@ -439,13 +431,13 @@ impl DirBuilder {

`

439

431

``

440

432

`pub fn mkdir(&self, path: &Path) -> io::Result<()> {

`

441

433

`run_path_with_cstr(path, &|path| {

`

442

``

`-

cvt(unsafe { hermit_abi::mkdir(path.as_ptr(), self.mode) }).map(|_| ())

`

``

434

`+

cvt(unsafe { hermit_abi::mkdir(path.as_ptr(), self.mode.into()) }).map(|_| ())

`

443

435

`})

`

444

436

`}

`

445

437

``

446

438

`#[allow(dead_code)]

`

447

439

`pub fn set_mode(&mut self, mode: u32) {

`

448

``

`-

self.mode = mode as u32;

`

``

440

`+

self.mode = mode;

`

449

441

`}

`

450

442

`}

`

451

443

``

`@@ -501,8 +493,9 @@ impl FromRawFd for File {

`

501

493

`}

`

502

494

``

503

495

`pub fn readdir(path: &Path) -> io::Result {

`

504

``

`-

let fd_raw =

`

505

``

`-

run_path_with_cstr(path, &|path| cvt(unsafe { hermit_abi::opendir(path.as_ptr()) }))?;

`

``

496

`+

let fd_raw = run_path_with_cstr(path, &|path| {

`

``

497

`+

cvt(unsafe { hermit_abi::open(path.as_ptr(), O_RDONLY | O_DIRECTORY, 0) })

`

``

498

`+

})?;

`

506

499

`let fd = unsafe { FileDesc::from_raw_fd(fd_raw as i32) };

`

507

500

`let root = path.to_path_buf();

`

508

501

``