Thought as much, but "Store all" would still pull my ammo and foodstuffs, at least, and usually I have a couple tools in the bag as well (shovel, wrench, pickaxe) and some wood/irons/repair kits. Less effort to "pull them back", sure, but I'd forget half my stuff in the box anyway
The lock would apply to selected part of the backpack - either some kind of manual select (tickboxes or "paintable" area or something else - all of which would require at least couple hundred lines of UI code, of a sort you're not using yet, so, I'm not hoping for that), or just "everything in the backpack at the moment of the click of the button" which would still require the locking logic, but UI-wise just a single button. Maybe a highlighted background for the locked items.
In my head it's a lock icon next to the sort-button, but since the store all / store dupes would require some new interactions, maybe something related there.