android NDK 的 lockf() 实现

发布于 2024-11-15 07:26:15 字数 158 浏览 8 评论 0原文

Android NDK 缺少 lockf() 函数。 当我使用 Android NDK 编译 CUPS 时,出现了缺少 lockf() 的错误。 因此,需要为 NDK 创建类似于 lockf() 的函数。 请帮助我创建这样的功能。

任何帮助将不胜感激。

PS:我是菜鸟

The Android NDK lacks the lockf() function.
While I was compiling CUPS with Android NDK, the error came of missing lockf().
Hence there is need to create function similar to lockf() for NDK.
Please help me in creating such a function.

Any help will be highly appreciated.

PS:I m a noob

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断桥再见 2024-11-22 07:26:15

这是另一个 Google 产品的处理方式

// The lockf() function is not available on Android; we translate to flock().
#define F_LOCK LOCK_EX
#define F_ULOCK LOCK_UN
inline int lockf(int fd, int cmd, off_t ignored_len) {
    return flock(fd, cmd);
}

https://src.chromium .org/svn/branches/1312/src/base/os_compat_android.h

This is how another Google produce handles it

// The lockf() function is not available on Android; we translate to flock().
#define F_LOCK LOCK_EX
#define F_ULOCK LOCK_UN
inline int lockf(int fd, int cmd, off_t ignored_len) {
    return flock(fd, cmd);
}

https://src.chromium.org/svn/branches/1312/src/base/os_compat_android.h

愛放△進行李 2024-11-22 07:26:15

即使您实现了 lockf(),使用它仍然会遇到一些问题,因为 Android 的权限管理受到限制。通常,两个进程不会同时拥有同一目录的读/写权限。我的意思是,您没有目录来放置要锁定的文件。

Even if you implement the lockf() you'll still have some problems using it, because Android has a restricted permission management. Generally two processes won't both have read/write permission on a same directory. I mean, you have no directory to place this file to be locked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文