首页
统计
关于
Search
1
C语言:获取程序运行消耗的时间(gettimeofday)
564 阅读
2
QT-利用Qcamera查看USB摄像头参数(数据帧格式+分辨率)
388 阅读
3
嵌入式linux组播接收发送失败解决
371 阅读
4
CMAKE报告:COULD NOT FIND PKGCONFIG (MISSING: PKG_CONFIG_EXECUTABLE)
355 阅读
5
Linux 查看硬盘通电时间
298 阅读
编程语言
C/C++
PHP
Go
分享
随笔
Linux
OpenHarmony
登录
Search
标签搜索
C++
QT
Linux
Git
Go
C
程序执行时间
函数执行时间
GDAL
zeromq
github
Centos
代理
goKit
gitea
247.1
累计撰写
34
篇文章
累计收到
0
条评论
首页
栏目
编程语言
C/C++
PHP
Go
分享
随笔
Linux
OpenHarmony
页面
统计
关于
搜索到
16
篇与
的结果
2025-09-18
Centos 所有的空间扩容给home
步骤 1:确认卷组和物理卷信息首先查看当前 LVM 卷组(VG)和物理卷(PV)的状态:vgdisplay centos # 查看 centos 卷组的剩余空间 pvdisplay # 查看已加入 LVM 的物理卷如果 centos 卷组本身已有未分配空间(Free PE / Size 不为 0),可直接跳到步骤 4;否则需要将其他空闲磁盘(如 /dev/sdb 等)加入 LVM。步骤 2:将空闲磁盘初始化为物理卷(PV)以 /dev/sdb 为例(其他空闲磁盘如 /dev/sdc 等可同理操作):bash确认磁盘未被使用(已挂载的需先卸载)umount /data1 # 如果 /dev/sdb 已挂载到 /data1,先卸载 # 将磁盘初始化为 LVM 物理卷(会清除磁盘数据,务必确认数据已备份!) pvcreate /dev/sdb如果需要添加多个磁盘(如 /dev/sdb 到 /dev/sdh),可批量执行:for disk in /dev/sd{b,c,d,e,f,g,h}; do umount /data$(echo $disk | sed 's/\/dev\/sd//') # 卸载对应挂载点 pvcreate $disk done步骤 3:将物理卷(PV)加入 centos 卷组(VG)# 将 /dev/sdb 加入 centos 卷组(多个磁盘用空格分隔) vgextend centos /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh再次确认卷组空闲空间:vgdisplay centos # 此时 Free PE / Size 应显示新增的空间步骤 4:扩展 /home 逻辑卷(LV)# 扩展逻辑卷(将所有空闲空间分配给 /home,+100%FREE 表示使用全部空闲空间) lvextend -l +100%FREE /dev/mapper/centos-home步骤 5:扩展文件系统(使扩容生效)由于 CentOS 的 /home 通常使用 XFS 文件系统(若为 ext4 则用 resize2fs),需执行:xfs_growfs /dev/mapper/centos-home验证扩容结果df -h /home # 查看 /home 分区的空间是否已增加最后一步就是删除/etc/fstab里面的挂在项,不然会出现开机异常
2025年09月18日
10 阅读
0 评论
0 点赞
2025-07-17
银河麒麟上QT应用自动创建桌面快捷方式及增加自启动
银河麒麟使用的桌面为MATE桌面。#include <QCoreApplication> #include <QFile> #include <QTextStream> #include <QDir> #include <QMessageBox> #include <QStandardPaths> #include <QFileInfo> #include <QProcess> bool shortcutExists(const QString& appName) { // 获取桌面路径 QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); if (desktopPath.isEmpty()) { qDebug() << "无法获取桌面路径"; return false; } // 构建.desktop文件路径 QString desktopFileName = appName + ".desktop"; QString desktopFilePath = desktopPath + QDir::separator() + desktopFileName; // 检查文件是否存在 return QFile::exists(desktopFilePath); } bool isAutostartEnabled(const QString& appName) { // 获取自动启动目录 QString autostartDir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/autostart/"; QString autostartFilePath = autostartDir + appName + ".desktop"; // 检查自动启动文件是否存在 return QFile::exists(autostartFilePath); } QString findApplicationIcon(const QString& appName, const QString& execPath) { // 获取可执行文件所在目录 QFileInfo execFileInfo(execPath); QString execDir = execFileInfo.absolutePath(); // 检查目录下是否存在logo.png QString logoPath = execDir + QDir::separator() + "logo.png"; if (QFile::exists(logoPath)) { qDebug() << "找到应用图标:" << logoPath; return logoPath; } // 尝试查找其他可能的图标文件 QStringList possibleIcons = { "icon.png", appName.toLower() + ".png", appName.toLower() + ".svg", "application-x-executable" // 默认应用图标 }; for (const QString& icon : possibleIcons) { QString iconPath = execDir + QDir::separator() + icon; if (QFile::exists(iconPath)) { qDebug() << "找到替代图标:" << iconPath; return iconPath; } } // 如果没有找到自定义图标,使用系统默认图标 qDebug() << "未找到自定义图标,使用默认图标"; return "application-x-executable"; // 系统默认应用图标 } bool createDesktopShortcut(const QString& appName, const QString& execPath, const QString& iconPath = "", const QString& comment = "", bool terminal = false, bool mateSpecific = true) { // 获取桌面路径 QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); if (desktopPath.isEmpty()) { qDebug() << "无法获取桌面路径"; return false; } // 构建.desktop文件路径 QString desktopFileName = appName + ".desktop"; QString desktopFilePath = desktopPath + QDir::separator() + desktopFileName; // 创建文件 QFile file(desktopFilePath); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { qDebug() << "无法创建文件:" << desktopFilePath; return false; } // 写入文件内容 QTextStream out(&file); out << "[Desktop Entry]\n"; out << "Version=1.0\n"; out << "Type=Application\n"; out << "Name=" << appName << "\n"; if (!comment.isEmpty()) out << "Comment=" << comment << "\n"; out << "Exec=" << execPath << "\n"; out << "Terminal=" << (terminal ? "true" : "false") << "\n"; // 使用提供的图标路径或默认图标 QString effectiveIcon = !iconPath.isEmpty() ? iconPath : "application-x-executable"; out << "Icon=" << effectiveIcon << "\n"; // MATE桌面特定配置 if (mateSpecific) { out << "X-MATE-Autostart-enabled=true\n"; out << "X-MATE-Autostart-Delay=0\n"; out << "X-MATE-Provides=panelapplet\n"; out << "Categories=GNOME;GTK;Utility;\n"; } else { out << "Categories=Application;\n"; } file.close(); // 设置文件权限为可执行 QFileInfo fileInfo(desktopFilePath); QFile::setPermissions( desktopFilePath, fileInfo.permissions() | QFileDevice::ExeUser | QFileDevice::ExeGroup | QFileDevice::ExeOther ); qDebug() << "桌面快捷方式已创建:" << desktopFilePath; // 刷新MATE桌面(可选) QProcess::startDetached("mate-panel --replace &"); return true; } bool enableAutostart(const QString& appName, const QString& execPath, const QString& iconPath = "", const QString& comment = "", bool terminal = false, bool mateSpecific = true) { // 获取自动启动目录 QString autostartDir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/autostart/"; QString autostartFilePath = autostartDir + appName + ".desktop"; // 创建自动启动目录(如果不存在) QDir().mkpath(autostartDir); // 创建文件 QFile file(autostartFilePath); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { qDebug() << "无法创建自动启动文件:" << autostartFilePath; return false; } // 写入文件内容 QTextStream out(&file); out << "[Desktop Entry]\n"; out << "Version=1.0\n"; out << "Type=Application\n"; out << "Name=" << appName << "\n"; if (!comment.isEmpty()) out << "Comment=" << comment << "\n"; out << "Exec=" << execPath << "\n"; out << "Terminal=" << (terminal ? "true" : "false") << "\n"; // 使用提供的图标路径或默认图标 QString effectiveIcon = !iconPath.isEmpty() ? iconPath : "application-x-executable"; out << "Icon=" << effectiveIcon << "\n"; // 自动启动特定配置 out << "NoDisplay=true\n"; out << "Hidden=false\n"; out << "X-GNOME-Autostart-enabled=true\n"; out << "X-MATE-Autostart-enabled=true\n"; // MATE桌面特定配置 if (mateSpecific) { out << "X-MATE-Autostart-Delay=0\n"; out << "Categories=GNOME;GTK;Utility;\n"; } else { out << "Categories=Application;\n"; } file.close(); // 设置文件权限 QFileInfo fileInfo(autostartFilePath); QFile::setPermissions( autostartFilePath, fileInfo.permissions() | QFileDevice::ExeUser | QFileDevice::ExeGroup | QFileDevice::ExeOther ); qDebug() << "已启用开机自启动:" << autostartFilePath; return true; } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // 获取应用信息 QString appName = QCoreApplication::applicationName(); QString execPath = QCoreApplication::applicationFilePath(); QString comment = "My Qt Application for MATE Desktop"; // 查找应用图标 QString iconPath = findApplicationIcon(appName, execPath); // 检查并创建桌面快捷方式 if (!shortcutExists(appName)) { if (createDesktopShortcut(appName, execPath, iconPath, comment, false, true)) { qDebug() << "MATE桌面快捷方式创建成功!"; } else { qDebug() << "MATE桌面快捷方式创建失败!"; return 1; } } else { qDebug() << "桌面快捷方式已存在,跳过创建"; } // 检查并启用开机自启动 if (!isAutostartEnabled(appName)) { if (enableAutostart(appName, execPath, iconPath, comment, false, true)) { qDebug() << "已成功设置开机自启动!"; } else { qDebug() << "开机自启动设置失败!"; return 1; } } else { qDebug() << "开机自启动已启用,跳过设置"; } return 0; }
2025年07月17日
30 阅读
0 评论
0 点赞
2024-09-17
error while loading shared libraries: libmpfr.so.4: cannot open shared object file
在Ubuntu22上编译QT出现这个错误error while loading shared libraries: libmpfr.so.4: cannot open shared object file加载共享库时出错:libmpfr.so.4:无法打开共享对象文件:没有这样的文件或目录解决办法:sudo ln -s /usr/lib/x86_64-linux-gnu/libmpfr.so.6 /usr/lib/x86_64-linux-gnu/libmpfr.so.4
2024年09月17日
93 阅读
0 评论
0 点赞
2024-09-11
Linux通用串口数据接收代码
#include <iostream> #include <thread> #include <mutex> #include <termios.h> #include <string.h> #include <poll.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <string.h> #include <signal.h> #include <pthread.h> using namespace std; int fd; void serial_read() { int nread; int BUFSIZE = 1024; unsigned char buff[BUFSIZE]; unsigned char *pbuff = NULL; struct timeval tv; fd_set rfds; tv.tv_sec = 2; tv.tv_usec = 0; while (true) { FD_ZERO(&rfds); FD_SET(fd, &rfds); if (select(1 + fd, &rfds, NULL, NULL, &tv) > 0) { if (FD_ISSET(fd, &rfds)) { pbuff = buff; nread = read(fd, buff, BUFSIZE); printf("Recv Len = %d\n", nread); for (int i = 0; i < nread; i++) { printf("0x%x ", buff[i]); } printf("\n"); memset(buff, 0, sizeof(buff)); } } } } int main() { if ((fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) { printf("err: can't open serial port!\n"); return -1; } struct termios options; tcgetattr(fd, &options); bzero(&options, sizeof(options)); options.c_cflag |= B115200 | CLOCAL | CREAD; options.c_cflag &= ~CSIZE; options.c_cflag |= CS8; options.c_cflag &= ~CSTOPB; options.c_cflag &= ~PARENB; tcflush(fd, TCIOFLUSH); if (tcsetattr(fd, TCSANOW, &options) != 0) return -1; thread th(serial_read); th.join(); return 0; }
2024年09月11日
64 阅读
0 评论
0 点赞
2024-07-14
go语言使用代理访问网址--goKit
http和https网页均可适用go get github.com/xingcxb/goKitpackage main import( "fmt" "github.com/xingcxb/goKit/core/httpKit" ) func main() { /// get请求 // 白名单认证 fmt.Println(httpKit.HttpProxyGet("https://cip.cc", "22.33.44.55:59582")) fmt.Println("------------------>") // 用户名密码认证 fmt.Println(httpKit.HttpProxyGetFull("https://cip.cc", nil, nil, "", 300, "http", "username", "password", "22.3.44.55:9582")) fmt.Println("------------------>") /// post请求 // 白名单认证 fmt.Println(httpKit.HttpProxyPost("https://cip.cc", nil, "22.33.44.55:59582")) fmt.Println("------------------>") // 用户名密码认证 fmt.Println(httpKit.HttpProxyPostFull("https://cip.cc", nil, nil, "", 300, "http", "username", "password", "22.33.44.55:59582")) }
2024年07月14日
46 阅读
0 评论
0 点赞
1
2
...
4