Giter VIP home page Giter VIP logo

Comments (4)

andrewdavidmackenzie avatar andrewdavidmackenzie commented on June 7, 2024

I'll take a look to see how it's currently converted to String. Would be a breaking API change for current users though....so maybe need a variant of the method....

from libproc-rs.

andrewdavidmackenzie avatar andrewdavidmackenzie commented on June 7, 2024

For MacOS (Darwin):

The source here: https://opensource.apple.com/source/Libc/Libc-594.9.4/darwin/libproc.c is not exactly "replete with comments" about the type of string it writes into the buffer.

It calls __proc_info(2, pid, PROC_PIDPATHINFO, (uint64_t)0, buffer, buffersize);

I couldn't find the docs for that yet. Source is here: https://opensource.apple.com/source/xnu/xnu-792.13.8/bsd/kern/proc_info.c
It looks like that ends up calling vn_getpath(), which I'm still trying to find...it's header only says:

/*!
 @function vn_getpath
 @abstract Construct the path to a vnode.
 @discussion Paths to vnodes are not always straightforward: a file with multiple hard-links will have multiple pathnames,
 and it is sometimes impossible to determine a vnode's full path.  vn_getpath() will not enter the filesystem.
 @param vp The vnode whose path to obtain.
 @param pathbuf Destination for pathname; should be of size MAXPATHLEN
 @param len Destination for length of resulting path string.  Result will include NULL-terminator in count--that is, "len"
 will be strlen(pathbuf) + 1.
 @return 0 for success or an error code.
 */

I wonder if any/all of these strings in the Mach/Darwin kernel are UTF-8?

For Linux:
I don't know, would have to investigate more.

Do you have knowledge of either/both OS to confirm the kernels can return buffers with non-UTF-8 strings for paths.
If so, I'd have to create a PathBuf from the raw buffer I imagine.

from libproc-rs.

andrewdavidmackenzie avatar andrewdavidmackenzie commented on June 7, 2024

I've just read two complete books on Mac OS X & iOS internals that covers BSD layer, Darwin, XNU, libSystem, libproc and the syscall wrappers - and annoyingly UTF and the nature of these strings returned in the buffers from syscals wasn't mentioned anywhere! :-(

from libproc-rs.

andrewdavidmackenzie avatar andrewdavidmackenzie commented on June 7, 2024

I guess this could use OSString?

Any suggestions on how to improve this to help improve for you?

from libproc-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.