Skip to content

Commit

Permalink
rust updates (w/ bonus llvm assertion :/)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
cuviper committed Mar 23, 2015
1 parent f6dcaae commit db151bc
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 59 deletions.
35 changes: 19 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use fuse;
use fuse::{self, FileType};
use git2;
use libc;
use libc::consts::os::posix88;
use std::old_io::{FileType, USER_FILE};

use inode;

Expand Down Expand Up @@ -39,7 +38,7 @@ impl inode::Inode for Blob {
size: self.size,
blocks: inode::st_blocks(self.size),
kind: FileType::RegularFile,
perm: USER_FILE,
perm: 0644,
..attr
})
}
Expand Down
8 changes: 4 additions & 4 deletions src/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use fuse::FileType;
use git2;
use libc;
use libc::consts::os::posix88;
use std::collections::hash_map;
use std::old_io::FileType;
use std::old_path::PosixPath;
use std::path::Path;

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

/// Read directory entries from this Inode.
fn readdir<'a>(&'a mut self, _repo: &git2::Repository, _offset: u64,
_add: Box<FnMut(Id, FileType, &PosixPath) -> bool + 'a>
_add: Box<FnMut(Id, FileType, &Path) -> bool + 'a>
) -> Result<(), libc::c_int> {
Err(posix88::ENOTDIR)
}
Expand Down
22 changes: 10 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#![feature(asm)]
#![feature(core)]
#![feature(libc)]
#![feature(old_io)]
#![feature(old_path)]
#![feature(std_misc)]

#![deny(missing_docs)]
Expand All @@ -25,13 +23,13 @@ extern crate git2;
extern crate libc;
extern crate time;

use fuse::FileType;

use std::collections::hash_map;
use std::default::Default;
use std::ffi::CString;
use std::ffi::OsString;
use std::ffi::{OsString, AsOsStr};
use std::os::unix::ffi::OsStrExt;
use std::fs;
use std::old_io::FileType;
use std::old_path::PosixPath;
use std::path::{AsPath, Path, PathBuf};
use std::u64;

Expand Down Expand Up @@ -112,8 +110,8 @@ impl GitFS {
mtime: self.epoch,
ctime: self.epoch,
crtime: self.epoch,
kind: FileType::Unknown,
perm: Default::default(),
kind: FileType::RegularFile, /* unknown... */
perm: 0,
nlink: 1,
uid: self.uid,
gid: self.gid,
Expand All @@ -139,8 +137,8 @@ impl fuse::Filesystem for GitFS {
Ok(())
}

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

Expand Down Expand Up @@ -233,11 +231,11 @@ impl fuse::Filesystem for GitFS {
match inode.and_then(|inode| {
if offset == 0 {
offset += 1;
reply.add(u64::MAX, offset, FileType::Directory, &PosixPath::new("."));
reply.add(u64::MAX, offset, FileType::Directory, &Path::new("."));
}
if offset == 1 {
offset += 1;
reply.add(u64::MAX, offset, FileType::Directory, &PosixPath::new(".."));
reply.add(u64::MAX, offset, FileType::Directory, &Path::new(".."));
}
inode.readdir(repo, offset - 2, Box::new(|id, kind, path| {
offset += 1;
Expand Down
12 changes: 6 additions & 6 deletions src/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use fuse::FileType;
use git2;
use libc;
use libc::consts::os::posix88;
use std::collections::hash_map;
use std::default::Default;
use std::old_io::{FileType, USER_DIR};
use std::old_path::PosixPath;
use std::path::{Path, PathBuf};

use inode;


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

impl RefDir {
Expand All @@ -32,7 +32,7 @@ impl RefDir {
}

impl inode::Inode for RefDir {
fn lookup(&mut self, _repo: &git2::Repository, name: &PosixPath
fn lookup(&mut self, _repo: &git2::Repository, name: &Path
) -> Result<inode::Id, libc::c_int> {
self.entries.get(name).cloned().ok_or(posix88::ENOENT)
}
Expand All @@ -44,13 +44,13 @@ impl inode::Inode for RefDir {
size: size,
blocks: inode::st_blocks(size),
kind: FileType::Directory,
perm: USER_DIR,
perm: 0755,
..attr
})
}

fn readdir<'a>(&mut self, _repo: &git2::Repository, offset: u64,
mut add: Box<FnMut(inode::Id, FileType, &PosixPath) -> bool + 'a>
mut add: Box<FnMut(inode::Id, FileType, &Path) -> bool + 'a>
) -> Result<(), libc::c_int> {
if offset < self.entries.len() as u64 {
for (path, &id) in self.entries.iter().skip(offset as usize) {
Expand Down
18 changes: 9 additions & 9 deletions src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use fuse::FileType;
use git2;
use libc;
use libc::consts::os::posix88;
use std::old_io::{FileType, USER_DIR};
use std::old_path::PosixPath;
use std::path::Path;

use inode;
use inode::{FileAttr, Id, Inode};
Expand All @@ -31,14 +31,14 @@ impl Root {
}

impl Inode for Root {
fn lookup(&mut self, repo: &git2::Repository, name: &PosixPath
fn lookup(&mut self, repo: &git2::Repository, name: &Path
) -> Result<Id, libc::c_int> {
if name.as_vec() == b"HEAD" {
if name == Path::new("HEAD") {
repo.head().ok()
.and_then(|head| head.target())
.map(|oid| Id::Oid(oid))
}
else if name.as_vec() == b"refs" {
else if name == Path::new("refs") {
Some(self.refs)
}
else { None }.ok_or(posix88::ENOENT)
Expand All @@ -51,19 +51,19 @@ impl Inode for Root {
size: size,
blocks: inode::st_blocks(size),
kind: FileType::Directory,
perm: USER_DIR,
perm: 0755,
..attr
})
}

fn readdir<'a>(&mut self, _repo: &git2::Repository, offset: u64,
mut add: Box<FnMut(Id, FileType, &PosixPath) -> bool + 'a>
mut add: Box<FnMut(Id, FileType, &Path) -> bool + 'a>
) -> Result<(), libc::c_int> {
if offset == 0 {
add(self.head, FileType::Unknown, &PosixPath::new("HEAD"));
add(self.head, FileType::Directory, &Path::new("HEAD"));
}
if offset <= 1 {
add(self.refs, FileType::Unknown, &PosixPath::new("refs"));
add(self.refs, FileType::Directory, &Path::new("refs"));
}
Ok(())
}
Expand Down
19 changes: 10 additions & 9 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use fuse::FileType;
use git2;
use libc;
use libc::consts::os::posix88;
use std::old_io::{FileType, USER_DIR};
use std::old_path::PosixPath;
use std::path::AsPath;
use std::ffi::OsStr;
use std::os::unix::ffi::OsStrExt;
use std::path::{AsPath, Path};

use inode;
use inode::{FileAttr, Id, Inode};
Expand All @@ -37,7 +38,7 @@ impl Tree {
}

impl Inode for Tree {
fn lookup(&mut self, repo: &git2::Repository, name: &PosixPath
fn lookup(&mut self, repo: &git2::Repository, name: &Path
) -> Result<Id, libc::c_int> {
self.tree(repo).and_then(|tree| {
match tree.get_path(name.as_path()) {
Expand All @@ -53,13 +54,13 @@ impl Inode for Tree {
size: self.size,
blocks: inode::st_blocks(self.size),
kind: FileType::Directory,
perm: USER_DIR,
perm: 0755,
..attr
})
}

fn readdir<'a>(&'a mut self, repo: &git2::Repository, offset: u64,
mut add: Box<FnMut(Id, FileType, &PosixPath) -> bool + 'a>
mut add: Box<FnMut(Id, FileType, &Path) -> bool + 'a>
) -> Result<(), libc::c_int> {
let len = self.size;
self.tree(repo).map(|tree| {
Expand All @@ -71,10 +72,10 @@ impl Inode for Tree {
let kind = match e.kind() {
Some(git2::ObjectType::Tree) => FileType::Directory,
Some(git2::ObjectType::Blob) => FileType::RegularFile,
_ => FileType::Unknown,
_ => FileType::CharDevice, /* something weird?!? unknown... */
};
let path = PosixPath::new(e.name_bytes());
if add(Id::Oid(e.id()), kind, &path) {
let os_path = <OsStr as OsStrExt>::from_bytes(e.name_bytes());
if add(Id::Oid(e.id()), kind, Path::new(os_path)) {
break;
}
}
Expand Down

0 comments on commit db151bc

Please sign in to comment.