Skip to content

(cargo) not installing with +x permissions (stat? chmod?) #2456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
killerswan opened this issue May 27, 2012 · 3 comments
Closed

(cargo) not installing with +x permissions (stat? chmod?) #2456

killerswan opened this issue May 27, 2012 · 3 comments

Comments

@killerswan
Copy link
Contributor

The quick fix may be to just run the system cp binary on unix platforms, but tracking down a relatively cross-platform way to stat and chmod files is probably worth the trouble.

Then the os::copy_file function should perhaps be modified to copy permissions, too...

There are a whole lot of posix functions in libc.rs, but I haven't seen a stat or fstat function there yet. Am I missing it or is this a gap?

@killerswan
Copy link
Contributor Author

cc @erickt

So this is an example which shows how to use libc::chmod, but I haven't found or created a way to use stat to get the permission I want to copy in the first place yet.

fn chmod(filepath: str, mode: i32) -> i32 {
   import libc::types::os::arch::posix88::mode_t;

   ret str::as_c_str(filepath, {|fp| libc::chmod(fp, mode as mode_t) });
}

fn cp(src: str, dest: str) {
   // What I'd like to do is something like so,
   // but where's the stat function?
   //
   //let st = libc::stat(src);
   //let mm = st.mode;

   let mm = 493_i32; /* octal 755 */
   os::copy_file(src, dest);
   chmod(dest, mm);
}

fn main() {
   cp("./dir/a", "./dir2/a");
}

@killerswan
Copy link
Contributor Author

Title changed to reflect further information: stat simply hasn't been added to the libc bindings yet.

@killerswan
Copy link
Contributor Author

Actually, I don't need to track this in an issue.

celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
tshepang pushed a commit to tshepang/rust that referenced this issue Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant