最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

filesystems - How to safely obtain a name for a mapper when using LUKS? - Stack Overflow

programmeradmin0浏览0评论

I am writing a script that unlocks a LUKS encryped partition (or file) using the command:

cryptsetup luksOpen /path/to/file mappername

Here, mappername is a name I have to provide for a file that will be placed at /dev/mapper/ and which then will be mounted to access the encrypted data.

But, in a script, how can I be sure that the name is available? It also seems that it is not possible (please correct me if I am wrong here!) to provide a custom path to place the mapper somewhere else, where I know the names of other files. If the name is already in use, the above command will fail.

This situation is also similar to the creation of a temporary file, where race conditions may occur between checking whether the file exists and the actual creation. Thus, what is the proper way to achieve this?

发布评论

评论列表(0)

  1. 暂无评论