Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright Intel Corp. 2018 */
0003 #include <linux/init.h>
0004 #include <linux/module.h>
0005 #include <linux/moduleparam.h>
0006 #include <linux/nd.h>
0007 #include "pmem.h"
0008 #include "pfn.h"
0009 #include "nd.h"
0010 #include "nd-core.h"
0011 
0012 ssize_t security_show(struct device *dev,
0013         struct device_attribute *attr, char *buf)
0014 {
0015     struct nvdimm *nvdimm = to_nvdimm(dev);
0016 
0017     /*
0018      * For the test version we need to poll the "hardware" in order
0019      * to get the updated status for unlock testing.
0020      */
0021     nvdimm->sec.flags = nvdimm_security_flags(nvdimm, NVDIMM_USER);
0022 
0023     if (test_bit(NVDIMM_SECURITY_DISABLED, &nvdimm->sec.flags))
0024         return sprintf(buf, "disabled\n");
0025     if (test_bit(NVDIMM_SECURITY_UNLOCKED, &nvdimm->sec.flags))
0026         return sprintf(buf, "unlocked\n");
0027     if (test_bit(NVDIMM_SECURITY_LOCKED, &nvdimm->sec.flags))
0028         return sprintf(buf, "locked\n");
0029     return -ENOTTY;
0030 }