Permission error while creating lock file
-
I creat one app with Qt,i want to open serial ,but failed,the error message is "permission error while creating lock file",why?
-
Hi
If on Linux, your user that you
are logged it with might no have access
else please give a bit details on platform,. Qt version and show some code. -
on android4.4.2
-
Hi
Ok then it might the old issue
https://forum.qt.io/topic/41857/solved-qserialport-in-qt-5-3-running-in-android/2
"
During opening of QtSerialPort tries to create lock-files in directories /var/lock, /etc/locks... /data/local/tmp.
On linux, some of these directories have the rights for writing from the usual user... so, no problem. But on Android, seems that these directories available only for root user, so, probably this is a problem for your application."(kuzulis wrote QSerialPort)
I though it was fixed / change in newer Qt but seems not.
-
my qt version is 5.9.the android must be rooted?
-
-
how can i read and write /var ,/etc ,/tmp and others files without root the android.
-
@angelatyizhong said in Permission error while creating lock file:
how can i read and write /var ,/etc ,/tmp and others files without root the android
You can't write there on Android without rooting the device, that's what @mrjj said.
-
other serial app can work OK without root the android.How should i set the QT app to make it OK without root the android.
-
@angelatyizhong something has to have root access, if not your application, than a driver, or the driver has to be baked in the OS, highly unlikely for non rooted Android devices.
Only alternative is talking via the android USB api to your device. Thats going to take time to write and I'm not convinced it will work correctly in the first place.
-
i find one source code witch can work ok without root the android.can i do with QT like this?how can i do?/
/检查访问权限,如果没有读写权限,进行文件操作,修改文件访问权限
if (!device.canRead() || !device.canWrite()) {
try {
//通过挂载到linux的方式,修改文件的操作权限
Process su = Runtime.getRuntime().exec("/system/xbin/su");
String cmd = "chmod 777 " + device.getAbsolutePath() + "\n" + "exit\n";
su.getOutputStream().write(cmd.getBytes());if ((su.waitFor() != 0) || !device.canRead() || !device.canWrite()) { throw new SecurityException(); } } catch (Exception e) { e.printStackTrace(); throw new SecurityException(); }
-
@angelatyizhong I really doubt su works on a non-rooted Android. See https://android.stackexchange.com/questions/207623/what-special-privileges-system-xbin-su-does-have-w-r-t-root-access
-
@angelatyizhong said in Permission error while creating lock file:
/system/xbin/su
take your time and read this answer, it's very detailed and good
https://android.stackexchange.com/a/207902TLDR:
Debug only -
BTW: QSerialPort officially does not support on Android. You even has not rights to open the device there (without of a root rights). One exception when it is possible - it if yours is an Android BSP developer and provides your Android devices with the pre-configured kernel and other stuff.
-
my android is rooted ,how can i send chmod order?
-
@angelatyizhong said in Permission error while creating lock file:
how can i send chmod order?
Do you mean from your app? Using QProcess.
-
It is strange why the lock-file creation fails for you. Because the source code of QSP is the following:
static const QStringList lockDirectoryPaths = QStringList() << QStringLiteral("/var/lock") << QStringLiteral("/etc/locks") << QStringLiteral("/var/spool/locks") << QStringLiteral("/var/spool/uucp") << QStringLiteral("/tmp") << QStringLiteral("/var/tmp") << QStringLiteral("/var/lock/lockdev") << QStringLiteral("/run/lock") #ifdef Q_OS_ANDROID << QStringLiteral("/data/local/tmp") #endif << QStandardPaths::writableLocation(QStandardPaths::TempLocation);
So, even "/data/local/tmp" or "QStandardPaths::TempLocation" does not work? If so, maybe you need to configure and the Android permissions, using a Manifest file? I meant the permissions to the temporary directories...
Anyway, you can try to find a writable temporary directory himself (just do separate non-QSP related tests), and then I can add your new solution to the QSP.