天道酬勤,学无止境

linux

In C on linux how would you implement cp

Question I've found on google code that was over 50 lines long and that's completely unnecessary for what I'm trying to do. I want to make a very simple cp implementation in C. Just so I can play with the buffer sizes and see how it affects performance. I want to use only Linux API calls like read() and write() but I'm having no luck. I want a buffer that is defined as a certain size so data from file1 can be read into buffer and then written to file2 and that continues until file1 has reached EOF. Here is what I tried but it doesn't do anything #include <stdio.h> #include <sys/types.h>

2022-07-11 09:46:32    分类:技术分享    c   linux   copy

Inability of Linux Kernel to support 1GB physical memory and the HIGHMEM solution

Question I have been reading [1] to have an idea about the HIGHMEM. The article says that "If the kernel wishes to be able to access the system's physical memory directly, however, it must set up page tables which map that memory into the kernel's part of the address space" .That is exactly where I have confusion. What do they mean by accessing physical memory directly? Does that mean explicitly stating the physical address?(AFAIK, that is not possible in Linux kernel) Then they go on stating that "it must set up page tables which map that memory into the kernel's part of the address space"

2022-07-11 09:34:35    分类:技术分享    linux   linux-kernel   operating-system   kernel   virtual-memory

How to enable hocr font info in tesseract 4?

Question I'm using tessseract 4 on ubuntu 16.04. so when using hocr feature in tesseract and after activating font info in hocr config file (hocr_font_info 1) I'm still not getting " x_font "info. Is there any other way to enable font info in tesseract4?

2022-05-17 04:31:53    分类:技术分享    linux   tesseract   hocr

Error on mount through php "exec"

Question I'm trying to mount an iscsi virtual disk, but if I execute the command through the exec function in php this give me that error: mount: special device /dev/sdf1 does not exist. But if I run the command directly in the console it run well!! What can I do? I'm obtaining the /dev/sdf1 in a good way, and it exists, but only through php doesn't work. Thanks I'm running the command with sudo and run it in console as www-data user always with sudo, so, I suppose that is the same enviroment. sudo mount -t ext3 /dev/sdf1 /san_disks/RIBS_2 The sudoers file has this lines: www-data ALL = (root)

2022-05-17 04:31:17    分类:技术分享    php   linux   exec   mount   ISCSI

Get vendor name of SCSI

Question How can I get the vendor name of SCSI device on linux & c? Answer1 You could look into reading /sys files if you know the device/bus id, also check lsscsi. -> cat /sys/bus/scsi/devices/target13:0:0/13:0:0:0/vendor Marvell Answer2 (1)open SCSI device. (2)Send SCSI command "inquiry" by ioctl. then you can get vendor name from the data returned. Answer3 The sg3_utils package contains utilities that send SCSI commands to devices. Once we have sg3_utils installed, run sg_inq command on the device you are interested in. For example: #sg_inq /dev/sda The above command will run standard SCSI

2022-05-17 03:30:04    分类:技术分享    c   linux   SCSI

Capturing stdout in Azure Linux App Service via NodeJs

Question I have deployed a NodeJS application to Linux App Service that logs to stderr and stdout. The diagnostic logs functionality in Linux App Service does not appear to work, as nothing appears in table storage. The only logs in Kudu are from when the docker container is deployed. After that, it logs nothing. The SSH component in Kudu does not work, even after following the official setup documentation. Has anyone come up with a way to capture stdout and stderr? or can recommend a library that they have gotten to work successfully with NodeJS on the Linux App Service platform? Answer1 You

2022-05-17 03:29:53    分类:技术分享    node.js   linux   azure   azure-web-app-service

How to view syslog in ubuntu?

Question Follow up from this question, LogBack Syslog not working java I use command below to view syslog in ubuntu 16.04 but get below result. Is it the correct way to view? user@xxx:~$ tail -f /var/log/syslog Jun 6 23:08:50 xxx systemd[1]: Starting Hostname Service... Jun 6 23:08:50 xxx dbus[889]: [system] Successfully activated service 'org.freedesktop.hostname1' Jun 6 23:08:50 xxx systemd[1]: Started Hostname Service. Jun 6 23:09:41 xxx gnome-session[2645]: (nautilus:2860): Gtk-WARNING **: Attempting to read the recently used resources file at '/home/xxx/.local/share/recently-used.xbel'

2022-05-17 03:27:04    分类:技术分享    linux   ubuntu   logging   sys

Bypassing SSL Certificate Validation on DotNet Core Service Stack

Question I know that ServicePointManager.ServerCertificateValidationCallback no longer exists in .Net Core and is instead replaced with: using(var handler = new System.Net.Http.HttpClientHandler()) { using (var httpClient = new System.Net.Http.HttpClient(handler)) { handler.ServerCertificateCustomValidationCallback = (request, cert, chain, errors) => { return true; }; } } However we are currently using the ServiceStack.Core library which, as far as I can see, does not expose either a property like this or the handler itself. How would I tell a ServiceStack client to bypass ssl validation in

2022-05-17 03:25:36    分类:技术分享    c#   linux   servicestack   .net-core

How can Linux ptrace be unsafe or contain a race condition?

Question I'd like to implement a sandbox by ptrace()ing a process I start and all its children would create (including grandchildren etc.). The ptrace() parent process, i.e. the supervisor. would be a simple C or Python program, and conceptually it would limit filesystem access (based on the path name and the access direction (read or write) and socket access (e.g. disallowing socket creation). What should I pay attention to so that the ptrace()d process and its children (recursively) won't be able to bypass the sandbox? Is there anything special the supervisor should do at fork() time to

2022-05-17 01:11:29    分类:技术分享    linux   sandbox   ptrace

Does anyone know a workaround for no-new-privileges blocking selinux transitions in docker?

Question I'm trying to run (any) container under docker with the no-new-privileges flag and Selinux enabled. Basic Info: CentOS 7.3 on bare metal docker-ce 17.05.0-ce (edge) from official repo docker-ce-selinux 17.05.0-ce (edge) from official repo (I was originally running stable, and switched to the edge release hoping for a fix) What I'm trying to do: docker run --security-opt "no-new-privileges" -it --rm busybox /bin/sh What happens: standard_init_linux.go:178: exec user process caused "operation not permitted" All features are supported - Selinux works when no-new-privileges is not

2022-05-17 01:11:04    分类:技术分享    linux   docker   SELinux