Open-source News

How I create music playlists on Linux

opensource.com - Wed, 07/13/2022 - 15:00
How I create music playlists on Linux Rikard Grossma… Wed, 07/13/2022 - 03:00 2 readers like this 2 readers like this

I recently wrote a C program in Linux to create a smaller random selection of MP3 files from my extensive MP3 library. The program goes through a directory containing my MP3 library, and then creates a directory with a random, smaller selection of songs. I then copy the MP3 files to my smartphone to listen to them on the go.

Sweden is a sparsely populated country with many rural areas where you don't have full cell phone coverage. That's one reason for having MP3 files on a smartphone. Another reason is that I don't always have the money for a streaming service, so I like to have my own copies of the songs I enjoy.

You can download my application from its Git repository. I wrote it for Linux specifically in part because it's easy to find well-tested file I/O routines on Linux. Many years ago, I tried writing the same program on Windows using proprietary C libraries, and I got stuck trying to get the file copying routing to work. Linux gives the user easy and direct access to the file system.

In the spirit of open source, it didn't take much searching before I found file I/O code for Linux to inspire me. I also found some code for allocating memory which inspired me. I wrote the code for random number generation.

The program works as described here:

  1. It asks for the source and destination directory.
  2. It asks for the number of files in the directory of MP3 files.
  3. It searches for the percentage (from 1.0 to 88.0 percent) of your collection that you wish to copy. You can also enter a number like 12.5%, if you have a collection of 1000 files and wish to copy 125 files from your collection rather than 120 files. I put the cap at 88% because copying more than 88% of your library would mostly generate a collection similar to your base collection. Of course, the code is open source so you can freely modify it to your liking.
  4. It allocates memory using pointers and malloc. Memory is required for several actions, including the list of strings representing the files in your music collection. There is also a list to hold the randomly generated numbers.
  5. It generates a list of random numbers in the range of all the files (for example, 1 to 1000, if the collection has 1000 files).
  6. It copies the files.

Some of these parts are simpler than others, but the code is only about 100 lines:

#include #include #include #include /* include necessary header files */ #include #include #include #include #define BUF_SIZE 4096 /* use buffer of 4096 bytes */ #define OUTPUT_MODE 0700 /*protect output file */ #define MAX_STR_LEN 256 int main(void) { DIR *d; struct dirent *dir; char strTemp[256], srcFile[256], dstFile[256], srcDir[256], dstDir[256]; char **ptrFileLst; char buffer[BUF_SIZE]; int nrOfStrs=-1, srcFileDesc, dstFileDesc, readByteCount, writeByteCount, numFiles; int indPtrFileAcc, q; float nrFilesCopy; //vars for generatingRandNumList int i, k, curRanNum, curLstInd, numFound, numsToGen, largNumRange; int *numLst; float procFilesCopy; printf("Enter name of source Directory\n"); scanf("%s", srcDir); printf("Enter name of destionation Directory\n"); scanf("%s", dstDir); printf("How many files does the directory with mp3 files contain?\n"); scanf("%d", &numFiles); printf("What percent of the files do you wish to make a random selection of\n"); printf("enter a number between 1 and 88\n"); scanf("%f", &procFilesCopy); //allocate memory for filesList, list of random numbers ptrFileLst= (char**) malloc(numFiles * sizeof(char*)); for (i=0; id_name); if(strTemp[0]!='.'){ nrOfStrs++; strcpy(ptrFileLst[nrOfStrs], strTemp); } } closedir(d); } for(q=0; q<=curLstInd; q++){ indPtrFileAcc=numLst[q]; strcpy(srcFile,srcDir); strcat(srcFile, "/"); strcat(srcFile,ptrFileLst[indPtrFileAcc]); strcpy(dstFile,dstDir); strcat(dstFile, "/"); strcat(dstFile,ptrFileLst[indPtrFileAcc]); srcFileDesc = open(srcFile, O_RDONLY); dstFileDesc = creat(dstFile, OUTPUT_MODE); while(1){ readByteCount = read(srcFileDesc, buffer, BUF_SIZE); if(readByteCount<=0) break; writeByteCount = write(dstFileDesc, buffer, readByteCount); if(writeByteCount<=0) exit(4); } //close the files close(srcFileDesc); close(dstFileDesc); } }

This code is possibly the most complex:

while(1){ readByteCount = read(srcFileDesc, buffer, BUF_SIZE); if(readByteCount<=0) break; writeByteCount = write(dstFileDesc, buffer, readByteCount); if(writeByteCount<=0) exit(4); }

More Linux resources Linux commands cheat sheet Advanced Linux commands cheat sheet Free online course: RHEL technical overview Linux networking cheat sheet SELinux cheat sheet Linux common commands cheat sheet What are Linux containers? Our latest Linux articles

This reads a number of bytes (readByteCount) from a file specified into the character buffer. The first parameter to the function is the file name (srcFileDesc). The second parameter is a pointer to the character buffer, declared previously in the program. The last parameter of the function is the size of the buffer.

The program returns the number of the bytes read (in this case, 4 bytes). The first if clause breaks out of the loop if a number of 0 or less is returned.

If the number of read bytes is 0, then all of the writing is done, and the loop breaks to write the next file. If the number of bytes read is less than 0, then an error has occurred and the program exits.

When the 4 bytes are read, it will write to them.The write function takes three arguments.The first is the file to write to, the second is the character buffer, and the third is the number of bytes to write (4 bytes). The function returns the number of bytes written.

If 0 bytes are written, then a write error has occurred, so the second if clause exits the program.

The while loop reads and copies the file, 4 bytes at a time, until the file is copied. When the copying is done, you can copy the directory of randomly generated mp3 files to your smartphone.

The copy and write routine are fairly efficient because they use file system calls in Linux.

Improving the code

This program is simple and it could be improved in terms of its user interface, and how flexible it is. You can implement a function that calculates the number of files in the source directory so you don't have to enter it manually, for instance. You can add options so you can pass the percentage and path non-interactively.nBut the code does what I need it to do, and it's a demonstration of the simple efficiency of the C programming language.

Use this C program I made on Linux to listen to your favorite songs on the go.

Image by:

Opensource.com

Programming Audio and music What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

The RADV Driver Developer Experience Working With AMD's Next-Gen Geometry "NGG"

Phoronix - Wed, 07/13/2022 - 15:00
Mesa's Radeon Vulkan "RADV" driver contributor Timur Kristóf known for being one of the Valve contractors to improve the open-source Linux graphics stack has shared his experiences working on the Next-Gen Geometry (NGG) support for AMD RDNA GPUs with this open-source driver...

Linux Lite – An Ubuntu-Based Distribution for Linux Newbies

Tecmint - Wed, 07/13/2022 - 12:32
The post Linux Lite – An Ubuntu-Based Distribution for Linux Newbies first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Linux Lite is a free, easy-to-use, and open-source Linux distribution based on the Ubuntu LTS series of releases. By design, it is a lightweight and user-friendly distribution that was developed with Linux beginners in

The post Linux Lite – An Ubuntu-Based Distribution for Linux Newbies first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

XWayland 22.1.3 Released Due To XKB Security Vulnerabilities

Phoronix - Wed, 07/13/2022 - 12:00
Disclosed on Tuesday were two new X.Org Server security vulnerabilities concerning possible local privilege escalation and remote code execution. X.Org Server 21.1.4 was released with these mitigations to the XKB extension while XWayland is also vulnerable and has now been patched with XWayland 22.1.3...

Enabling Open Source Projects with Impactful Engineering Experience

The Linux Foundation - Wed, 07/13/2022 - 05:17

This post originally appeared on the FINOS Community Blog. The author, James McLeod, is the Director of Community at the Fintech Open Source Foundation, a project of the Linux Foundation. You may also want to listen to the Open Source in Finance podcast

I often talk about “engineering experience” and the importance for open source projects to provide fast, easy and impactful ways for open source consumers to realise return on engagement. Just like e-commerce stores that invest in user experience to encourage repeat sales, successful open source projects provide a slick installation, well written contextual documentation and a very compelling engagement model that encourages collaboration.

In fact, within the open source community, it’s possible to drive commitment to open source projects through “engineering experience”. Successful projects develop lives of their own and build communities of thousands that flock to repos, Meetups and in-person events.

This article is focused on the “engineering experience” related to automation and deployment, but future articles will also cover providing an engaging README.md, contextual documentation and the workflows needed to engage new and experienced open source contributors.

ENGINEERING EXPERIENCE PROVIDES DAY ZERO OPEN SOURCE VALUE

The risk of ignoring an open source project’s “engineering experience” is the project becoming a lifeless repository waiting for a community to discover them. Imagine the questions that have been answered in dormant repos that could be solving real world problems if engagement was easy.

At FINOS we’re driven to provide day zero value to financial services engineers looking to utilise FINOS open source projects. This philosophy is demonstrated by FINOS projects like LegendWaltzPerspective and FDC3 that engage in open source methodologies for ease of installation.

Without engaging in a healthy “engineering experience”, engineer teams might find themselves working through reams of documentation, setting flags and system settings that could take days to configure and test against each and every operating system on their route to production.

The scenario highlighted above has been mitigated by FINOS projects Legend and Waltz by using Juju and Charms, an open source framework that enables easy installation and automated operations across hybrid cloud environments. Without Juju and Charms, Legend and Waltz would need to be manually installed and configured for every single project instance.

By engaging Juju and Charms, Legend and Waltz are shipped using a method that enables the projects to be installed across the software development lifecycle. This accelerator provides a positive “engineering experience” whilst increasing engineering velocity and saving development and infrastructure costs.

From the very first point of contact, open source projects should be smooth and simple to understand, install, deploy and leverage. The first set of people an open source project will meet on its journey to success is the humble developer looking for tools to accelerate projects.

Hybrid cloud and containerisation is a powerful example of how projects should be presented to engineers to vastly improve end-to-end engineering experience, another is the entire node.js and JavaScript ecosystem.

ENGINEERING EXPERIENCE ENABLES NODE.JS AND JAVASCRIPT OPEN SOURCE DEVELOPMENT

Take node.js and the various ways the node ecosystem can be maintained. I’m a massive fan of Node Version Manager, an open source project that enables the node community to install and traverse versions of node from a simple and easy to engage command line tool.

Node Version Manager removes the requirement to install, uninstall and reinstall different versions of node on your computer from downloaded binaries. Node Version Manager runs on your local computer and manages the version of node needed with simple bash commands.

After installing nvm with a simple curl of the latest install.sh, Node Version Manager is now running on your local computer, Mac in my case, and node can be installed with nvm install node. Such a simple way to keep the node.js community engaged, updated and supported. Not only this, but the vast open source world of JavaScript can now be leveraged.

With Node Version Manager provided as an open source tool, the further “engineering experience” of yarn and npm can be explored. Which enables FINOS projects, like Perspective and FDC3, to be installed using node.js to accelerate the financial services industry with simple commands like yarn add @finos/perspective and yarn add @finos/fdc3.

The chaining together of “engineering experience”, that removes the pain of manual configuration by leveraging containers and command line automation, not only invites experimentation, but it’s contributed greatly to the exponential success of open source itself.

As the articles move through the different ways to engage open source communities to make open source projects successful, it would be great to hear your “engineering experience” experiences by emailing james.mcleod@finos.org or by raising a GitHub issue on the FINOS Community Repo.

The post Enabling Open Source Projects with Impactful Engineering Experience appeared first on Linux Foundation.

The Linux Foundation Announces Conference Schedule for Open Source Summit Europe 2022

The Linux Foundation - Wed, 07/13/2022 - 04:18

The premier event in Europe for open source code and community contributors features 200+ sessions across 13 micro-conferences, covering the pivotal topics and technologies at the core of open source.

SAN FRANCISCO, July 12, 2022 —  The Linux Foundation, the nonprofit organization enabling mass innovation through open source, today announced the full schedule for Open Source Summit Europe, the leading conference for open source developers, technologists, and community leaders. The event is taking place September 13-16 in Dublin, Ireland and virtually. The schedule can be viewed here.

OS Summit Europe will feature a robust program of 325+ talks across 13 micro-conferences covering the most essential and cutting edge topics in open source: Linux Systems, Supply Chain Security, AI + Data, OSPOs, Community Leadership, Embedded IoT, Cloud, Diversity, Containers, Embedded Linux and more.

2022 Conference Session Highlights Include:

  • LinuxCon
    • Containers as an Illusion – Michael Kerrisk, man7.org
    • How to Report Your Linux Kernel Bug – Thorsten Leemhuis
  • Embedded Linux Conference
    • Booting Automotive ECUs Really Fast with Modern Security Features – Brendan Le Foll, BMW Car IT GmbH
    • From a Security Expert’s Diary: DOs and DON’Ts when Choosing Software for Your Next Embedded Product – Marta Rybczynska, Syslinbit
  • CloudOpen
    • Addressing the Transaction Challenge in a Cloud-native World – Grace Jansen, IBM
    • The Challenges and Solutions of Open Edge Infrastructures – Ildiko Vancsa, Open Infrastructure Foundation
  • OSPOCon
    • Building a Team for the Upstream: Things We Learned Building InnerSource Teams for Open Source Impact – Emma Irwin, Microsoft
    • A Practical Guide for Outbound Open Source – Which Scales and Can Be Adapted Easily for Companies of Different Size – Oliver Fendt, Siemens AG
  • Critical Software Summit
    • The Unexpected Demise of Open Source Libraries – Liran Tal, Snyk
    • Address Space Isolation for Enhanced Safety of the Linux Kernel – Igor Stoppa, NVIDIA
  • Emerging OS Forum
    • Demystifying the WASM Landscape: A Primer – Divya Mohan, SUSE
    • How Open Source Helps a Grid Operator with the Challenges of the Energy Transition – Jonas van den Bogaard & Nico Rikken, Alliander
  • SupplyChainSecurityCon
    • Composing the Ultimate SBOM – Ivana Atanasova & Velichka Atanasova, VMware
    • From Kubernetes With Open Tools For Open, Secure Supply Chains – Adolfo García Veytia, Chainguard
  • Diversity Empowerment Summit
    • Overcoming Imposter Syndrome to Become a Conference Speaker! – Dawn Foster, VMware
    • Teaching Collaboration to the Next Generation of Open Source Contributors – Ruth Suehle, Red Hat
  • Open Source On-Ramp
    • Debugging Embedded Linux – Marta Rybczynska, Syslinbit
    • Getting Started with Kernel-based Virtual Machine (KVM) – Leonard Sheng Sheng Lee, Computas
  • Open AI + Data Forum 
    • Beyond Neural Search: Hands-on Tutorial on Building Cross-Modal/Multi-Modal Solution with Jina AI – Han Xiao & Sami Jaghouar, Jina AI
    • Truly Open Lineage – Mandy Chessell, Pragmatic Data Research Ltd
  • ContainerCon
    • Evaluation of OSS Options to Build Container Images – Matthias Haeussler, Novatec
    • Interactive Debugging of Dockerfile With Buildg – Kohei Tokunaga, NTT Corporation
  • Community Leadership Conference
    • Panel Discussion: Growing Open Source in the Irish Government – Clare Dillon, Open Ireland Network; Tony Shannon, Department of Public Expenditure & Reform in Government of Ireland; Tim Willoughby, An Garda Síochána, Ireland’s Police Service; Gar Mac Criosta, Linux Foundation Public Health; John Concannon, Department of Foreign Affairs
    • Dev Team Metrics that Matter – Avishag Sahar, LinearB
  • Embedded IoT Summit 
    • Design of an Open Source, Modular, 5G Capable, Container Based, Scientific Data Capture Hexacopter – Mauro Borrageiro & Ngoni Mombeshora, University of Cape Town
    • Contributing to Zephyr vs (Linux and U-boot) – Parthiban Nallathambi, Linumiz

Keynote speakers will be announced in the coming weeks. 

Registration (in-person) is offered at the early price of $850 through July 17. Registration to attend virtually is $25. Members of The Linux Foundation receive a 20 percent discount off registration and can contact events@linuxfoundation.org to request a member discount code. 

Applications for diversity and need-based scholarships are currently being accepted. For information on eligibility and how to apply, please click here. The Linux Foundation’s Travel Fund is also accepting applications, with the goal of enabling open source developers and community members to attend events that they would otherwise be unable to attend due to a lack of funding. To learn more and apply, please click here.

Health and Safety
In-person attendees will be required to be fully vaccinated against the COVID-19 virus and will need to comply with all on-site health measures, in accordance with The Linux Foundation Code of Conduct. To learn more, visit the Health & Safety webpage.

Event Sponsors
Open Source Summit Europe 2022 is made possible thanks to our sponsors, including Diamond Sponsors: AWS, Google and IBM, Platinum Sponsors: Huawei and Intel, and Gold Sponsors: Cloud Native Computing Foundation, Codethink, Docker, Mend, Red Hat, and Styra. For information on becoming an event sponsor, click here or email us.

Press
Members of the press who would like to request a press pass to attend should contact Kristin O’Connell.

ABOUT THE LINUX FOUNDATION
Founded in 2000, the Linux Foundation and its projects are supported by more than 2,950 members. The Linux Foundation is the world’s leading home for collaboration on open source software, hardware, standards, and data. Linux Foundation projects are critical to the world’s infrastructure including Linux, Kubernetes, Node.js, ONAP, Hyperledger, RISC-V, and more. The Linux Foundation’s methodology focuses on leveraging best practices and addressing the needs of contributors, users, and solution providers to create sustainable models for open collaboration. For more information, please visit us at https://linuxfoundation.org/

The Linux Foundation Events are where the world’s leading technologists meet, collaborate, learn and network in order to advance innovations that support the world’s largest shared technologies.

Visit our website and follow us on Twitter, LinkedIn, and Facebook for all the latest event updates and announcements.

The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see its trademark usage page: www.linuxfoundation.org/trademark-usage. Linux is a registered trademark of Linus Torvalds. 

###

Media Contact

Kristin O’Connell
The Linux Foundation
koconnell@linuxfoundation.org

The post The Linux Foundation Announces Conference Schedule for Open Source Summit Europe 2022 appeared first on Linux Foundation.

"Retbleed" Published As Arbitrary Speculative Execution With Return Instructions

Phoronix - Wed, 07/13/2022 - 01:34
Being made public this Patch Tuesday is "RETBLEED" as two new CVEs for the latest speculative execution attacks affecting today's hardware. Retbleed exploits return instructions and is able to undermine existing defenses against Spectre Branch Target Injection (BTI)...

Intel Publishes Open-Source AI Reference Kits

Phoronix - Wed, 07/13/2022 - 01:22
Intel today announced the release of open-source "AI Reference Kits" to help in the development of artificial intelligence software around healthcare, manufacturing, and other fields...

Pages