Skip to content

Commit db151bc

Browse files
committed
rust updates (w/ bonus llvm assertion :/)
- cargo update - follow rust-fuse into new Path and private FileType Only lib.rs et al are updated so far, as it dies in llvm::checkGEPType: Assertion `Ty && "Invalid GetElementPtrInst indices for type!"' failed.
1 parent f6dcaae commit db151bc

File tree

7 files changed

+60
-59
lines changed

7 files changed

+60
-59
lines changed

Cargo.lock

Lines changed: 19 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/blob.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9-
use fuse;
9+
use fuse::{self, FileType};
1010
use git2;
1111
use libc;
1212
use libc::consts::os::posix88;
13-
use std::old_io::{FileType, USER_FILE};
1413

1514
use inode;
1615

@@ -39,7 +38,7 @@ impl inode::Inode for Blob {
3938
size: self.size,
4039
blocks: inode::st_blocks(self.size),
4140
kind: FileType::RegularFile,
42-
perm: USER_FILE,
41+
perm: 0644,
4342
..attr
4443
})
4544
}

src/inode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9+
use fuse::FileType;
910
use git2;
1011
use libc;
1112
use libc::consts::os::posix88;
1213
use std::collections::hash_map;
13-
use std::old_io::FileType;
14-
use std::old_path::PosixPath;
14+
use std::path::Path;
1515

1616
use blob;
1717
use tree;
@@ -34,7 +34,7 @@ pub enum Id {
3434
/// A generic interface for different Git object types to implement.
3535
pub trait Inode: Send {
3636
/// Find a directory entry in this Inode by name.
37-
fn lookup(&mut self, _repo: &git2::Repository, _name: &PosixPath
37+
fn lookup(&mut self, _repo: &git2::Repository, _name: &Path
3838
) -> Result<Id, libc::c_int> {
3939
Err(posix88::ENOTDIR)
4040
}
@@ -63,7 +63,7 @@ pub trait Inode: Send {
6363

6464
/// Read directory entries from this Inode.
6565
fn readdir<'a>(&'a mut self, _repo: &git2::Repository, _offset: u64,
66-
_add: Box<FnMut(Id, FileType, &PosixPath) -> bool + 'a>
66+
_add: Box<FnMut(Id, FileType, &Path) -> bool + 'a>
6767
) -> Result<(), libc::c_int> {
6868
Err(posix88::ENOTDIR)
6969
}

src/lib.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#![feature(asm)]
1212
#![feature(core)]
1313
#![feature(libc)]
14-
#![feature(old_io)]
15-
#![feature(old_path)]
1614
#![feature(std_misc)]
1715

1816
#![deny(missing_docs)]
@@ -25,13 +23,13 @@ extern crate git2;
2523
extern crate libc;
2624
extern crate time;
2725

26+
use fuse::FileType;
27+
2828
use std::collections::hash_map;
2929
use std::default::Default;
30-
use std::ffi::CString;
31-
use std::ffi::OsString;
30+
use std::ffi::{OsString, AsOsStr};
31+
use std::os::unix::ffi::OsStrExt;
3232
use std::fs;
33-
use std::old_io::FileType;
34-
use std::old_path::PosixPath;
3533
use std::path::{AsPath, Path, PathBuf};
3634
use std::u64;
3735

@@ -112,8 +110,8 @@ impl GitFS {
112110
mtime: self.epoch,
113111
ctime: self.epoch,
114112
crtime: self.epoch,
115-
kind: FileType::Unknown,
116-
perm: Default::default(),
113+
kind: FileType::RegularFile, /* unknown... */
114+
perm: 0,
117115
nlink: 1,
118116
uid: self.uid,
119117
gid: self.gid,
@@ -139,8 +137,8 @@ impl fuse::Filesystem for GitFS {
139137
Ok(())
140138
}
141139

142-
fn lookup(&mut self, _req: &fuse::Request, parent: u64, name: &PosixPath, reply: fuse::ReplyEntry) {
143-
if let Ok(name) = CString::new(name.as_vec()) {
140+
fn lookup(&mut self, _req: &fuse::Request, parent: u64, name: &Path, reply: fuse::ReplyEntry) {
141+
if let Ok(name) = name.as_os_str().to_cstring() {
144142
probe!(gitfs, lookup, parent, name.as_ptr());
145143
}
146144

@@ -233,11 +231,11 @@ impl fuse::Filesystem for GitFS {
233231
match inode.and_then(|inode| {
234232
if offset == 0 {
235233
offset += 1;
236-
reply.add(u64::MAX, offset, FileType::Directory, &PosixPath::new("."));
234+
reply.add(u64::MAX, offset, FileType::Directory, &Path::new("."));
237235
}
238236
if offset == 1 {
239237
offset += 1;
240-
reply.add(u64::MAX, offset, FileType::Directory, &PosixPath::new(".."));
238+
reply.add(u64::MAX, offset, FileType::Directory, &Path::new(".."));
241239
}
242240
inode.readdir(repo, offset - 2, Box::new(|id, kind, path| {
243241
offset += 1;

src/reference.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9+
use fuse::FileType;
910
use git2;
1011
use libc;
1112
use libc::consts::os::posix88;
1213
use std::collections::hash_map;
1314
use std::default::Default;
14-
use std::old_io::{FileType, USER_DIR};
15-
use std::old_path::PosixPath;
15+
use std::path::{Path, PathBuf};
1616

1717
use inode;
1818

1919

2020
/// Represents a virtual directory in reference paths
2121
/// (e.g. `refs/heads/master` needs intermediate `refs/` and `refs/heads/`)
2222
pub struct RefDir {
23-
entries: hash_map::HashMap<PosixPath, inode::Id>,
23+
entries: hash_map::HashMap<PathBuf, inode::Id>,
2424
}
2525

2626
impl RefDir {
@@ -32,7 +32,7 @@ impl RefDir {
3232
}
3333

3434
impl inode::Inode for RefDir {
35-
fn lookup(&mut self, _repo: &git2::Repository, name: &PosixPath
35+
fn lookup(&mut self, _repo: &git2::Repository, name: &Path
3636
) -> Result<inode::Id, libc::c_int> {
3737
self.entries.get(name).cloned().ok_or(posix88::ENOENT)
3838
}
@@ -44,13 +44,13 @@ impl inode::Inode for RefDir {
4444
size: size,
4545
blocks: inode::st_blocks(size),
4646
kind: FileType::Directory,
47-
perm: USER_DIR,
47+
perm: 0755,
4848
..attr
4949
})
5050
}
5151

5252
fn readdir<'a>(&mut self, _repo: &git2::Repository, offset: u64,
53-
mut add: Box<FnMut(inode::Id, FileType, &PosixPath) -> bool + 'a>
53+
mut add: Box<FnMut(inode::Id, FileType, &Path) -> bool + 'a>
5454
) -> Result<(), libc::c_int> {
5555
if offset < self.entries.len() as u64 {
5656
for (path, &id) in self.entries.iter().skip(offset as usize) {

src/root.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9+
use fuse::FileType;
910
use git2;
1011
use libc;
1112
use libc::consts::os::posix88;
12-
use std::old_io::{FileType, USER_DIR};
13-
use std::old_path::PosixPath;
13+
use std::path::Path;
1414

1515
use inode;
1616
use inode::{FileAttr, Id, Inode};
@@ -31,14 +31,14 @@ impl Root {
3131
}
3232

3333
impl Inode for Root {
34-
fn lookup(&mut self, repo: &git2::Repository, name: &PosixPath
34+
fn lookup(&mut self, repo: &git2::Repository, name: &Path
3535
) -> Result<Id, libc::c_int> {
36-
if name.as_vec() == b"HEAD" {
36+
if name == Path::new("HEAD") {
3737
repo.head().ok()
3838
.and_then(|head| head.target())
3939
.map(|oid| Id::Oid(oid))
4040
}
41-
else if name.as_vec() == b"refs" {
41+
else if name == Path::new("refs") {
4242
Some(self.refs)
4343
}
4444
else { None }.ok_or(posix88::ENOENT)
@@ -51,19 +51,19 @@ impl Inode for Root {
5151
size: size,
5252
blocks: inode::st_blocks(size),
5353
kind: FileType::Directory,
54-
perm: USER_DIR,
54+
perm: 0755,
5555
..attr
5656
})
5757
}
5858

5959
fn readdir<'a>(&mut self, _repo: &git2::Repository, offset: u64,
60-
mut add: Box<FnMut(Id, FileType, &PosixPath) -> bool + 'a>
60+
mut add: Box<FnMut(Id, FileType, &Path) -> bool + 'a>
6161
) -> Result<(), libc::c_int> {
6262
if offset == 0 {
63-
add(self.head, FileType::Unknown, &PosixPath::new("HEAD"));
63+
add(self.head, FileType::Directory, &Path::new("HEAD"));
6464
}
6565
if offset <= 1 {
66-
add(self.refs, FileType::Unknown, &PosixPath::new("refs"));
66+
add(self.refs, FileType::Directory, &Path::new("refs"));
6767
}
6868
Ok(())
6969
}

src/tree.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9+
use fuse::FileType;
910
use git2;
1011
use libc;
1112
use libc::consts::os::posix88;
12-
use std::old_io::{FileType, USER_DIR};
13-
use std::old_path::PosixPath;
14-
use std::path::AsPath;
13+
use std::ffi::OsStr;
14+
use std::os::unix::ffi::OsStrExt;
15+
use std::path::{AsPath, Path};
1516

1617
use inode;
1718
use inode::{FileAttr, Id, Inode};
@@ -37,7 +38,7 @@ impl Tree {
3738
}
3839

3940
impl Inode for Tree {
40-
fn lookup(&mut self, repo: &git2::Repository, name: &PosixPath
41+
fn lookup(&mut self, repo: &git2::Repository, name: &Path
4142
) -> Result<Id, libc::c_int> {
4243
self.tree(repo).and_then(|tree| {
4344
match tree.get_path(name.as_path()) {
@@ -53,13 +54,13 @@ impl Inode for Tree {
5354
size: self.size,
5455
blocks: inode::st_blocks(self.size),
5556
kind: FileType::Directory,
56-
perm: USER_DIR,
57+
perm: 0755,
5758
..attr
5859
})
5960
}
6061

6162
fn readdir<'a>(&'a mut self, repo: &git2::Repository, offset: u64,
62-
mut add: Box<FnMut(Id, FileType, &PosixPath) -> bool + 'a>
63+
mut add: Box<FnMut(Id, FileType, &Path) -> bool + 'a>
6364
) -> Result<(), libc::c_int> {
6465
let len = self.size;
6566
self.tree(repo).map(|tree| {
@@ -71,10 +72,10 @@ impl Inode for Tree {
7172
let kind = match e.kind() {
7273
Some(git2::ObjectType::Tree) => FileType::Directory,
7374
Some(git2::ObjectType::Blob) => FileType::RegularFile,
74-
_ => FileType::Unknown,
75+
_ => FileType::CharDevice, /* something weird?!? unknown... */
7576
};
76-
let path = PosixPath::new(e.name_bytes());
77-
if add(Id::Oid(e.id()), kind, &path) {
77+
let os_path = <OsStr as OsStrExt>::from_bytes(e.name_bytes());
78+
if add(Id::Oid(e.id()), kind, Path::new(os_path)) {
7879
break;
7980
}
8081
}

0 commit comments

Comments
 (0)