Wikipedia:Reference desk/Archives/Computing/2015 December 1

Computing desk
< November 30 << Nov | December | Jan >> December 2 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


December 1 edit

Setting write protection for only part of an SD card edit

Anyone know if the write-protection circuitry of SD cards allows for protecting only part of the memory? I'm not talking about the notch. — Melab±1 01:25, 1 December 2015 (UTC)[reply]

It depends on what exactly you mean. As I just learned from the article, every SD card actually has a portion of its memory "hidden" to the outside world, available for DRM content. But, if you mean a user-controllable functionality that allows you to mark parts of the card read-only, hypothetically it would be possible, but I don't believe such a thing is supported in the SD standard. The whole-card write-protection is actually not implemented in the card itself. A write-protected card simply tells host devices that it's write-protected, and it's up to the host device to obey this or not. To implement some kind of user-controlled "selective write-protect" you'd have to modify an SD card yourself by flashing the controller with custom firmware, or cracking it open and physically replacing the controller chip. And actually implementing such a feature in the firmware would be difficult. Flash memory controllers do all kinds of complex gymnastics under the hood for wear leveling and other purposes. The physical location of data in the memory can change every time there's a write. SD cards and similar devices like USB flash drives are designed as black boxes; it's not intended for users of the card to know or care about the internal memory layout. --71.119.131.184 (talk) 02:16, 1 December 2015 (UTC)[reply]
The SD card's controller does support write-protection. — Melab±1 21:50, 1 December 2015 (UTC)[reply]
If you want to protect part of the content, you can put on a file system that supports decent permissions and use those to protect those files from being accidentally (over)written - chmod ugo-w file12.txt. I don't know if FAT32, which is the default file system on modern SDHC cards, supports this. Note that reformatting a card will delete all existing content, and that many cameras do not support alternative file systems. --Stephan Schulz (talk) 15:13, 4 December 2015 (UTC)[reply]

Where is the Linux clipboard? edit

Clipboard_(computing)#X_Window_System is not very clear here. It might even be that this article needs some improvement. In what file exactly is the clipboard content stored? If the xclip tool is installed, would xclip save information to a different location? --Scicurious (talk) 13:20, 1 December 2015 (UTC)[reply]

The clipboard content is not stored in a file. It is held dynamically in memory by the X server. Looie496 (talk) 13:49, 1 December 2015 (UTC)[reply]
And how do programs refer to this information, when we copy-and-paste among them? Or all those clipboard tools, how to they access it? Be it in memory or not, Isn't there a file to be accessed? After all, in Linux, everything is supposed to be a file.--Scicurious (talk) 18:01, 1 December 2015 (UTC)[reply]
Your clipboard might be managed by your X server, or by some other system (like your Desktop Manager). For example, if you use Gnome, your clipboard is the GtkClipboard, a data structure that is designed to hold "data shared between different processes or between different widgets in the same process." Your clipboard will be incarnated differently if you use a different desktop manager or User Interface software.
The block of data that is your clipboard is shared memory, implemented by the user interface software and backed by a lower-level Linux data type; and neither of those things usually exist as a file. Some variants of *nix will allow you to open a file handle to such a shared memory abstraction, but that's an unusual way to access the resource.
"Everything" is not a file: when people say everything is a file, they usually mean everything from a specific set of things - things like directories, sockets, and pipes, as documented in this general overview of the Linux file system. Many other computer resources exist that are not files: memory is not a file; the power manager is not a file; certain types of special-purpose I/O are not files. If you wish to present these resources as ordinary files, you can (sometimes) wrap them inside a file handle (provided that you have privileges to access these resources); but there are plenty of cases where that does not make sense. For example, do you want Linux ACPI interfaces to be accessed in a file-like way? What does it mean to fopen the processor P-states? You could abstract that kind of operation, but a different paradigm already exists to read, modify, and protect those resources.
If you really want to pursue the "everything - no really, everything - is a file" paradigm and chase down that rabbit hole - Linux isn't the right choice for you. You might want to read about Plan 9 file servers - part of the Plan 9 from Bell Labs system. Plan 9 is installable; it is mostly functional; but it is not Linux. You might find that the "abstract entity" called a "file" in Plan 9 is not at all like what you think of when you use a more conventional operating system's file API.
Nimur (talk) 19:13, 1 December 2015 (UTC)[reply]
The short answer is that Linux doesn't have a clipboard. Linux is a kernel. This is sometimes given as a glib answer when it's not really relevant, but here it is. Whatever clipboard you have available is determined by whatever software you're using copy-and-paste in. The X Window System makes three different "clipboards" available to software. Each program is free to pick which one, or none, to use. Some programs like emacs and vim have their own "kill"/"yank" buffers that don't interface with GUI clipboards at all (because they're primarily designed to run in terminals). And you might not even be using X; there are alternatives like running programs directly in a framebuffer, and Wayland is intended as a replacement for X. Android uses the Linux kernel but doesn't use X or Wayland, so I don't even know what it does. This mess is a longtime pain point in FLOSS GUIs; Freedesktop.org has tried to get developers to commit to seamless clipboard use between programs, but as anyone familiar with the FLOSS world knows, it's like herding cats. --71.119.131.184 (talk) 20:21, 1 December 2015 (UTC)[reply]
Still, now that Scicurious mentions it, it is interesting that content which other systems would describe as "on the clipboard" isn't available through a filename under /dev or /proc. At least, as far as I know it isn't. --76.69.45.64 (talk) 21:38, 2 December 2015 (UTC)[reply]
Emacs does actually interact with the X clipoard (or at least the KDE one, in case they're not the same thing), when run in GUI mode, but not in the non-windowed mode (emacs -nw.) So, yes, programs can pick which mechanism to use, if any. Also, in neither case (and in contrast with Windows), does the killed (copied) content seem to survive the termination of the program from which the copying was done Asmrulz (talk) 16:20, 5 December 2015 (UTC) [reply]
That feature isn't in Linux. It is available in other systems: for example, Plan 9, publishes program memory as a file in procfs. You can use procfs /proc/n/mem to get to the memory image of your clipboard server (whether it is owned by your desktop UI program, by your X server, or by a dedicated daemon).
If you added this feature to Linux, replacing of all the parts of Linux that get in the way, eventually you'd have some other operating system. Some incarnations of such an operating system do already exist.
Nimur (talk) 23:31, 2 December 2015 (UTC)[reply]
Did you read the procfs article, which tells you it's existed since V8 Unix, and is part of the Linux kernel? But anyway, procfs doesn't include any specific clipboard function. It just gives you access to a process's memory. You can get any data you want out of it, if you're prepared to dissect the memory dump. The point I was trying to get across above is that the Linux kernel contains no clipboard. A "clipboard" is part of the desktop metaphor and is implemented in GUIs people run on top of Linux. You could propose that the kernel add a clipboard functionality that it makes available to processes, but it would probably be rejected as something that belongs in userspace. --71.119.131.184 (talk) 00:49, 3 December 2015 (UTC)[reply]
Sorry, it appears I am mistaken. Linux does publish process memory images via procfs, but it additionally restricts access to these special files by way of the prctl system call. Nimur (talk) 14:18, 3 December 2015 (UTC)[reply]